07 2013 档案
摘要:题目链接:http://poj.org/problem?id=1611#include #include #include #include #include #include #include #define maxn 30050#define INF 0x3f3f3fusing namespace std;int pa[maxn]; int find(int x){ return x == pa[x] ? x : pa[x] = find(pa[x]);}int main(){ int n,m; while(scanf("%d%d",&n,&m)){ .
阅读全文
摘要:题目链接:http://poj.org/problem?id=3084本题主要在构图上,我采用的是把要保护的房间与源点相连,有intruder的与汇点相连,相对麻烦。#include #include #include #include #include #include #include #define maxn 30#define maxe 5000 using namespace std;const int INF = 0x3f3f3f;struct Edge{ int from,to,cap,flow; int next;};struct Dinic{ int s,t...
阅读全文
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2609#include #include #include #include #include #include #include #define maxn 450#define maxe 100000 using namespace std;const int INF = 0x3f3f3f;struct Edge{ int from,to,cap,flow; int next;};struct Dinic{ int s,t; int h...
阅读全文
摘要:题目链接:http://acm.hrbeu.edu.cn/index.php?act=problem&id=1223 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 9 #define maxn 11510 using namespace std;11 12 const int INF = 0x3f3f3f;13 14 struct Point{15 double x,y;16 bool operator G[s][i]){46 ...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4618 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define maxn 305 9 using namespace std; 10 11 vector G[maxn*maxn]; 12 int a[maxn][maxn]; 13 int maxp; 14 int N,M; 15 16 bool find(int u,int v){ 17 ...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4614 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 9 #define maxn 105000 10 #define lson l,mid,u>1; 21 seg[u>1; 28 seg[u>1; 43 build(lson); 44 build(rson); 45 } 46 void Update(int...
阅读全文
摘要:题目链接:http://poj.org/problem?id=3468WA 在了数据类型上,seg[]要用longlong,输入也要注意. 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 9 #define maxn 12500010 #define lson l,mid,u>1;22 seg[u>1;37 build(lson);38 build(rson);39 PushUp(u);40 }41 void Update(int...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1698 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 9 #define maxn 13005010 #define lson l,mid,u mid) Update(L,R,num,rson);51 Push_UP(u);52 }53 54 int main()55 {56 if(freopen("input.txt","r",stdin...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2795 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 9 #define maxn 22222210 #define lson l,mid,u>1; 28 build(lson);29 build(rson);30 Push_UP(u);31 }32 void Update(int loc,int num,int l,int r,int u){33 ...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1754 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 9 #define maxn 23005010 #define lson l,mid,u mid) ret =max(ret,Query(L,R,rson));49 return ret;50 }51 int main()52 {53 if(freopen("input.txt","r",stdi
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4619 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define maxn 1001 9 #define N 10510 using namespace std;11 12 int map[N][N];13 bool G[maxn][maxn];14 int n,m;15 int ans;16 bool vis[maxn];17 int link[maxn];18 in...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4602我们可以特判出n 2 using namespace std; 3 const long long moder = 1e9 + 7; 4 5 long long power(long long t){ 6 if(t == 0) return 1; 7 long long ans = power(t/2) % moder; 8 ans = ans * ans % moder; 9 if(t % 2) ans = ans * 2 % moder;10 r...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4607首先如果k小于等于直径长度,那么答案为k−1。如果k大于直径长度,设直径长度为r,那么答案为r−1+(k−r)∗2。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define maxn 105000 9 using namespace std;10 11 const int INF = 0x3f3f3f;12 13 vector G[maxn];14 int N,M...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4608 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define maxn 105000 9 using namespace std;10 11 int len;12 char a[maxn],b[maxn]; 13 14 15 int getsum(){16 int ans = 0; //printf("%d\n",len);17 for(int i=0...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4604这个题解有点问题,暂时没时间改,还是参考别人的吧#include #include #include #include #include #include #include #define maxn 100500using namespace std;const int INF = 0x3f3f3f;int a[maxn];int s1[maxn],s2[maxn];int ans;int n;int search_lower_bound(int l,int h,int m){ if(l...
阅读全文
摘要:题目链接:http://poj.org/problem?id=3903 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define maxn 100005 9 using namespace std;10 11 int stack[maxn];12 int a[maxn];13 int n;14 15 int search_lower_bound(int l,int h,int m){16 if(l == h) return h;17 int mid ...
阅读全文
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3659 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 const int maxn = 200005; 9 int p[maxn],num[maxn];10 long long int sum[maxn];11 struct Edge{12 int u,v,c;13 bool operator rh.c;15 }16 ...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3367 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 const int maxn = 10005; 9 const int maxm = 100050;10 11 struct Edge{12 int u,v,c;13 bool operator rh.c;15 }16 };17 vector e;18 int p[maxn];19 int n,m; 2...
阅读全文
摘要:题目链接:http://acm.bupt.edu.cn/onlinejudge/newoj/showProblem/show_problem.php?problem_id=1578 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 10 using namespace std;11 int a,b;12 int calculatenum(int num){13 int ans = 0;14 while(num>0){15 ...
阅读全文
摘要:二分匹配 :http://www.byvoid.com/blog/hungary/zh-hans/很详细,图很多,容易理解矩阵乘法:http://www.matrix67.com/blog/archives/276/经典运用,出自Matrix67大牛之手
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #define maxn 105012 #define maxk 900013 using namespace std;14 15 int n,k;16 long long int size[maxn];17 bitset mask; //用来记录最后出现搜索的tags的编号;18 map > mmap;19 map >::iterator ...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define maxn 10005 9 #define L -110 #define R 111 #define fell 1012 #define Turning -1013 #define On 0;14 15 using namespace std;16 struct ants{17 int location;18 int direction;19 int inputorder;20 ...
阅读全文