上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 36 下一页

2011年5月27日

poj 1275

摘要: 代码:#include<iostream>#include<fstream>#include<queue>using namespace std;struct e{ int data; int cost; e *next;};e edge[25];int n,m;int r[25],num[25];void add(int s,int t,int w){ e *p=new e; p->data=t; p->cost=w; p->next=edge[s].next; edge[s].next=p;}int v[25];int ans;int 阅读全文

posted @ 2011-05-27 10:21 宇宙吾心 阅读(303) 评论(0) 推荐(0)

poj 1523

摘要: 代码:#include<iostream>#include<fstream>using namespace std;struct e{ int data; e *next;};e edge[1001];void add(int i,int j){ e *p=new e; p->data=j; p->next=edge[i].next; edge[i].next=p; e *q=new e; q->data=i; q->next=edge[j].next; edge[j].next=q;}int dfn[1001],v[1001],low[1001 阅读全文

posted @ 2011-05-27 09:46 宇宙吾心 阅读(211) 评论(0) 推荐(0)

poj 1112

摘要: 代码:#include<iostream>#include<fstream>#include<cmath>using namespace std;int n;struct e{ int data; e *next;};e edge[101];int v[101];void add(int s,int t){ e *p=new e; p->data=t; p->next=edge[s].next; edge[s].next=p;}int x[101],y[101],mark[101][101];int dfs(int s,int kind,int 阅读全文

posted @ 2011-05-27 09:41 宇宙吾心 阅读(404) 评论(0) 推荐(0)

2011年5月26日

poj 1144

摘要: 割点代码:#include<iostream>#include<fstream>using namespace std;int n;struct e{ int data; e *next;};e edge[101];int v[101],dfn[101],low[101],index;void solve(int s){ int i,j,k; dfn[s]=low[s]=++index; e *p=edge[s].next; v[s]=0; while(p) { if(dfn[p->data]==0) { solve(p->data); if(low[p-& 阅读全文

posted @ 2011-05-26 10:44 宇宙吾心 阅读(397) 评论(0) 推荐(0)

poj 2914

摘要: 最小割代码:#include<iostream>#include<fstream>using namespace std;int n,m;int map[501][501];int v[501],com[501],w[501];int cost;int S,T;void search(){ int i,j,k; int maxx; memset(v,0,sizeof(v)); memset(w,0,sizeof(w)); S=T=-1; while(1) { maxx=-1;k=-1; for(i=0;i<n;i++) if(!com[i]&&!v 阅读全文

posted @ 2011-05-26 10:19 宇宙吾心 阅读(411) 评论(0) 推荐(0)

2011年5月25日

poj 1681

摘要: 高斯消元代码:#include<iostream>#include<fstream>using namespace std;int move[5][2]={0,1,0,-1,1,0,-1,0,0,0};int n,m;int a[300][300];void solve(){ int i,j,k,s; j=0; for(i=0;i<n&&j<n;i++,j++) { for(k=i;k<n;k++) if(a[k][j]) break; if(k==n){ i--; continue; } if(k!=i) { for(s=j;s< 阅读全文

posted @ 2011-05-25 20:22 宇宙吾心 阅读(618) 评论(0) 推荐(0)

poj 1222

摘要: 高斯消元代码:#include<iostream>#include<fstream>using namespace std;int move[5][2]={0,0,0,1,0,-1,1,0,-1,0};int n,m;int map[31][31];int a[31][31];int x[31];void solve(){ int i,j,k,s,t; j=0; for(i=0;i<30&&j<30;i++,j++) { for(k=i;k<30;k++) if(a[k][j]==1) break; if(k==30) { i--; c 阅读全文

posted @ 2011-05-25 20:13 宇宙吾心 阅读(545) 评论(0) 推荐(0)

poj 1546

摘要: 代码:#include<iostream>#include<fstream>#include<cmath>using namespace std;int n,m;char c[10],c1[10];void read(){// ifstream cin("in.txt"); int i,j,k; while(cin>>c>>n>>m) { j=0; for(i=0;i<strlen(c);i++) { if(c[i]>='0'&&c[i]<='9 阅读全文

posted @ 2011-05-25 15:30 宇宙吾心 阅读(467) 评论(0) 推荐(0)

2011年5月19日

poj 1961

摘要: 题意:给出一个串,问你这个串的所有前缀,最多是由多少个相同的子串重复连接而成的。代码:#include<iostream>#include<fstream>using namespace std;char c[1000005];int next[1000004];int len;void get(){ int i,j,k; j=0;k=-1;next[0]=-1; while(j<len) if(k==-1||c[j]==c[k]) next[++j]=++k; else k=next[k];}void read(){// ifstream cin("i 阅读全文

posted @ 2011-05-19 17:07 宇宙吾心 阅读(363) 评论(0) 推荐(0)

poj 2406

摘要: 题意:给出一个串,问你这个最多是多少个相同的字串重复连接而成的。如:ababab则最多有3个ab连接而成。代码:#include<iostream>#include<fstream>using namespace std;char c[1000005];int next[1000004];int len;void get(){ int i,j,k; j=0;k=-1;next[0]=-1; while(j<len) if(k==-1||c[j]==c[k]) next[++j]=++k; else k=next[k];}void read(){// ifstrea 阅读全文

posted @ 2011-05-19 16:57 宇宙吾心 阅读(529) 评论(0) 推荐(0)

上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 36 下一页

导航