上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 22 下一页
摘要: 虚拟一个根节点n,设其值为0.并且始终保持其为根。#include#include#include#include#include#include#include#include#include#include#include#define Maxn 40010#define Maxm 100010#define LL __int64#define Abs(x) ((x)>0?(x):(-x))#define lson(x) (x num;void init(){ for(int i=0;i<Maxn;i++){ fa[i]=i; val[i]=0; }... 阅读全文
posted @ 2013-09-01 10:34 fangguo 阅读(185) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#include#include#include#include#include#include#include#include#define Maxn 1010#define Maxm 100010#define LL __int64#define Abs(x) ((x)>0?(x):(-x))#define lson(x) (x<<1)#define rson(x) (x<<1|1)#define inf 0x7fffffff#define Mod 1000000007using namespace std;in 阅读全文
posted @ 2013-08-30 20:38 fangguo 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 思路:每次合并时,都是给一个虚拟的根。#include#include#include#include#include#include#include#include#include#include#include#define Maxn 100010#define Maxm 2000010#define LL __int64#define Abs(x) ((x)>0?(x):(-x))#define lson(x) (x<<1)#define rson(x) (x<<1|1)#define inf 0x3f3f3f3f#define Mod 1000000007 阅读全文
posted @ 2013-08-29 19:58 fangguo 阅读(187) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#include#include#include#include#include#include#include#include#define Maxn 52#define Maxm 100010#define LL __int64#define Abs(x) ((x)>0?(x):(-x))#define lson(x) (xb?b:a;}int solve(){ int i,j,r,ki,kj,fi,fj,N; N=(1<<k)-1; dp[0][1][0]=0; for(ki=0;ki<=N;ki++){ ... 阅读全文
posted @ 2013-08-29 17:05 fangguo 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 思路:其实就是让每一条路有尽量多的人走。#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#define Maxn 100010#define Maxm 100010#define LL __int64#define Abs(x) ((x)>0?(x):(-x))#define lson(x) (x<<1)#define r 阅读全文
posted @ 2013-08-29 14:27 fangguo 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 思路:将每个回合的平手和赢最为一对对立状态。那么后面就是2-SAT判断了。#include#include#include#include#include#include#define Maxn 20010using namespace std;map g[Maxn];int vi[Maxn],head[Maxn],dfn[Maxn],low[Maxn],e,n,lab,top,num,id[Maxn],Stack[Maxn],wh[Maxn],hh[4][4];struct Edge{ int u,v,next;}edge[100000];void init()//初始化{ me... 阅读全文
posted @ 2013-08-29 14:25 fangguo 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 思路:这里必须要选择的点是2*k个,首先就是求一边斯坦纳树,然后做一次动态规划出每个状态下的最小值。#include#include#include#include#include#include#include#include#include#include#include#define Maxn 210#define Maxm 100010#define LL __int64#define Abs(x) ((x)>0?(x):(-x))#define lson(x) (x>=1) res+=(s&1)*(i=inf) printf("No solution\n 阅读全文
posted @ 2013-08-28 17:18 fangguo 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 思路:虚拟一个0号节点,将每个点建一条到0号节点的边,权值为挖井需要的价值。并要保证0号节点同另外n个寺庙一样被选择即可。然后就是求斯坦纳树了。#include#include#include#include#include#include#include#include#include#include#include#define Maxn 1310#define Maxm 100010#define LL __int64#define Abs(x) ((x)>0?(x):(-x))#define lson(x) (x q; dis[i][i]=0; q.push... 阅读全文
posted @ 2013-08-28 15:32 fangguo 阅读(301) 评论(0) 推荐(0) 编辑
摘要: 思路:直接先求一下最小生成树,然后用树形dp来求最优值。也就是两遍dfs。#include#include#include#include#include#define Maxn 2010using namespace std;struct Edge{ int u,v; double c; int operator Max[u]){ lMax[u]=Max[u]; Max[u]=Max[v]; road[u]=v; } else if(Max[v]>lMax[u]){ ... 阅读全文
posted @ 2013-08-26 17:41 fangguo 阅读(247) 评论(0) 推荐(0) 编辑
摘要: 思路:将边从大到小排序,判断向哪边连,能使总和最大。#include#include#include#include#include#include#include#include#include#include#include#define Maxn 200010#define Maxm 200010#define LL __int64#define Abs(x) ((x)>0?(x):(-x))#define lson(x) (xtemp.val; }}p[Maxn];int Set[Maxn];LL sum[Maxn],num[Maxn];int Find(int x){ i... 阅读全文
posted @ 2013-08-26 15:22 fangguo 阅读(207) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 22 下一页