上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 42 下一页
模板题,不解释了 Read More
posted @ 2012-02-22 16:04 Because Of You Views(199) Comments(0) Diggs(0) Edit
首先注意边是双向边,最短路的inf要取很大思路:增加一个源点,一个汇点,如果一个避雨点有a只奶牛,则从源点向这个点连一条边,容量为a,如果这个避雨点能容纳b只奶牛,则从这个点向汇点连一条容量为b的边。接着二分枚举答案,两点间最短路径的长度小于等于二分值的两个点能互相到达,连一条容量为无穷大的边这样子建好图后求最大流会发现样例都过不了,debug过程中发现如果1->2 , 2->3,那么1就会自动联通3,实际上1,3可能不连通,所以想到把点拆成两排,如果1,2连通,就从1连一条边到2+n,这样就不会出现上面的情况了,另外,连接汇点的点变成了n+1---2*n。敲完后果断还是WA,都快 Read More
posted @ 2012-02-22 15:18 Because Of You Views(431) Comments(0) Diggs(0) Edit
题意:安排C头奶牛到K个挤奶器,每个挤奶器最多能为M头牛挤奶,给出奶牛、挤奶器之间的额边的权值,求所有安排方案中,C头奶牛需要走的最大距离的最小值先求好原图中两两间的最短路径,再二分答案,验证是否能满足C头奶牛都能到达挤奶器,能的话就继续缩小范围具体验证方法:增加一个汇点,每个挤奶器向汇点连上一条容量为M的边,增加一个源点,向每只牛连一条容量为1的边,然后求一个s--t的最大流即可View Code #include<iostream>#include<string.h>#include<stdio.h>#include<queue>#defin Read More
posted @ 2012-02-21 21:50 Because Of You Views(340) Comments(0) Diggs(0) Edit
状态转移:dp[state][i]=sigma(dp[state'][i-1]);state和state'都是合法状态更多的注释在代码中View Code #include<cstdio>#include<cstring>int dp[13][1<<13];int cur[15];int state[1<<13];int m,n,tot;const int mod = 100000000;bool ok(int state){ if(state&(state<<1)) return false; return Read More
posted @ 2012-02-18 21:08 Because Of You Views(283) Comments(0) Diggs(0) Edit
hdu 2768,两个投票者矛盾的话就连一条边,总数减去最大匹配数就是要求的答案#include<cstdio>#include<cstring>#include<string>#include<vector>#include<iostream>using namespace std;bool vis[501];int match[501];vector<int> g[501];string a[505],b[505];bool dfs(int u){ for(int i=0;i<g[u].size();i++) { Read More
posted @ 2012-02-18 19:22 Because Of You Views(753) Comments(1) Diggs(0) Edit
做了两个多小时。。。。其实也还好求至少有三个长方体重叠的区域的体积交对z轴坐标离散化,对于每个高度,记录包含该高度的长方体的下表面,求至少覆盖三次的面积并求面积交同那道“覆盖的面积”,只不过这里是覆盖三次,稍微想的仔细一点应该不成问题再乘以(z[i+1]-z[i]),易知z[i+1]==所记录的长方体上表面的高的最小值,所以不用担心这样做的正确性View Code #include<cstdio>#include<cstring>#include<algorithm>using namespace std;typedef __int64 lld;const Read More
posted @ 2012-02-16 23:21 Because Of You Views(1002) Comments(3) Diggs(0) Edit
做这题必须头脑清晰,先想好步骤再写,模拟题就变得很简单了View Code #include<cstdio>#include<cstring>#include<algorithm>using namespace std;struct player{ int num; char name[25]; char role; int year;}p[30],ans[20],G[20],S[20],D[20],M[20];int cmp(player a,player b){ if(a.num==b.num) return a.year<b.year; retu Read More
posted @ 2012-02-15 15:32 Because Of You Views(261) Comments(0) Diggs(0) Edit
RelocationTime Limit:1000MSMemory Limit:65536KTotal Submissions:823Accepted:326DescriptionEmma and Eric are moving to their new house they bought after returning from their honeymoon. Fortunately, they have a few friends helping them relocate. To move the furniture, they only have two compact cars, Read More
posted @ 2012-02-15 14:19 Because Of You Views(774) Comments(0) Diggs(0) Edit
View Code #include<stdio.h>#include<string>#include<stack> using namespace std;int main(){ int m,i,j,k; char ch[1000],map[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int t; scanf("%d",&t); while(t--){ __int64 n=0; stack<int>s; scanf("%d%d%s",&a Read More
posted @ 2012-02-14 20:35 Because Of You Views(220) Comments(0) Diggs(0) Edit
View Code #include <iostream>#include <fstream>#include <cstring>#include <cmath>#include<cstdio>using namespace std;long long prime[16]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};long long bestSum;long long bestRes;long long N;void work(long long res,long long sum,int Read More
posted @ 2012-02-14 17:41 Because Of You Views(183) Comments(0) Diggs(1) Edit
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 42 下一页