摘要:
思路:将每个layer拆成两个点,编号为N+x,和N+N+x。对所有属于layer x的点i,建N+x到i的有向边,在建i到N+N+x的有向边。最后对所有x号layer和x+1建一条N+N+x到N+x+1的有向边和一条N+N+x+1到N+x的有向边。#include#include#include#include#include#include#include#include#include#include#define pb push_back#define mp make_pair#define Maxn 300010#define Maxm 80002#define LL __int64 阅读全文
摘要:
思路:把每个点拆成(d+1)*n列,行数为可拆分区间数。对所有的有i号点拆分出来的行都要建一条该行到i列的边,那么就能确保有i号点拆出来的行只能选择一行。#include#include#include#include#include#include#include#include#include#include#define pb push_back#define mp make_pair#define Maxn 1010#define Maxm 80002#define LL __int64#define Abs(x) ((x)>0?(x):(-x))#define lson(x) 阅读全文
摘要:
思路:裸的DLX重复覆盖#include#include#include#include#include#include#include#include#include#include#define pb push_back#define mp make_pair#define Maxn 51#define Maxm 80002#define LL __int64#define Abs(x) ((x)>0?(x):(-x))#define lson(x) (xK) return false; if(R[0]==0) return true; int i,j,temp,c; t... 阅读全文
摘要:
思路:dp[i][0]表示第i个节点为根的子树变成以i为一头的长链最小的花费,dp[i][0]表示表示第i个节点为根的子树变成i不是头的长链最小花费。那么动态方程也就不难想了,就是要分几个情况处理,细心就好。#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#define inf 10000000#define Maxn 1100010using namespace std;int vi[Maxn],head[Maxn],ans,e,d 阅读全文
摘要:
思路:其实这题是个挺水的动态规划,一开始就能AC,可是不知道错哪了,瞎改瞎交,WA了数十次。AC之后怎么改都是AC,也不知道改了什么地方,郁闷死了~~~难道开始时的测试数据有问题???dp[i][j]表示第i天在第j个地方的最大概率,那么dp[i][j]=max(dp[i][j],dp[i-1][k]+p[k][j]+we[i][weh[j]]);p[k][j]表示从k到j的概率,we[i][j]表示第i个地方出现j天气的概率。#include#include#include#include#include#include#define inf 100000000#define eps 1e- 阅读全文
摘要:
思路:二分枚举建边,用DLX判断是否满足。#include#include#include#include#include#include#include#include#include#include#define clr(x,y) memset(x,y,sizeof(x))#define pb push_back#define mp make_pair#define Maxn 20010#define LL __int64#define Abs(x) ((x)>0?(x):(-x))#define lson(x) (x m) return false; if (R[0] == 0) 阅读全文
摘要:
#include#include#include#include#include#include#include#include#include#include#define pb push_back#define mp make_pair#define Maxn 1000010#define Maxm 80002#define LL __int64#define Abs(x) ((x)>0?(x):(-x))#define lson(x) (x<<1)#define rson(x) (x<<1|1)#define inf 100000#define lowbit 阅读全文
摘要:
思路:这题的出题人是不是语文不行啊,题目意思说不清楚。知道是求存在路径的点对数后,用并查集每次记录集合中点的数目,很容易就解决了。#include#include#include#include#include#include#include#include#include#include#define pb push_back#define mp make_pair#define Maxn 200100#define Maxm 800002#define LL __int64#define Abs(x) ((x)>0?(x):(-x))#define lson(x) (x<< 阅读全文
摘要:
思路:直接打表#include#include#include#includeusing namespace std;int num[10010]={0,1356,1967,2577,3188,3799,5156,13154,13762,14374,14985,16341,16953,17563,18174,18785,20142,20753,21364,21975,22587,23942,24554,25165,25775,26387,27744,28355,28966,29576,30187,31544,32155,32767,33375,33987,35344,35954,36566,3 阅读全文
摘要:
思路:这个没思路,看了陈启峰的论文写得。#include#include#include#include#include#include#include#include#include#include#include#include#define pb push_back#define mp make_pair#define Maxn 1010#define Maxm 80002#define LL __int64#define Abs(x) ((x)>0?(x):(-(x)))#define lson(x) (xd[u]){dp[u][i]=inf;continue;} dp[... 阅读全文