随笔分类 -  图论

上一页 1 2 3 下一页

poj 2139
摘要:#include<iostream>#include<fstream>using namespace std;int map[301][301];int n,m;int a[301];void read(){// ifstream cin("in.txt"); int i,j,k,s,t; cin>>n>>m; memset(map,-1,sizeof(map)); for(i=1;i<=m;i++) { cin>>k; for(j=1;j<=k;j++) cin>>a[j]; for(s= 阅读全文

posted @ 2011-06-01 17:06 宇宙吾心 阅读(327) 评论(0) 推荐(0)

poj 2349
摘要:#include<iostream>#include<fstream>#include<cmath>using namespace std;int n,m;struct e{ int s,t; double w;};e edge[250001];int x[501],y[501];int top;void add(int s,int t,double w){ edge[++top].s=s; edge[top].t=t; edge[top].w=w;};int cmp(const void *a,const void *b){ if( (*(e*)a).w& 阅读全文

posted @ 2011-06-01 17:02 宇宙吾心 阅读(275) 评论(0) 推荐(0)

poj 2075
摘要:#include<iostream>#include<fstream>using namespace std;struct e{ int s,t; double w;};e edge[250001];int n,m;char c[501][30];int cmp(const void *a,const void *b){ if ((*(e*)a).w>(*(e*)b).w) return 1; return -1;}int top;void add(int s,int t,double w){ edge[++top].s=s; edge[top].t=t; edg 阅读全文

posted @ 2011-06-01 17:01 宇宙吾心 阅读(253) 评论(0) 推荐(0)

poj 2394
摘要:#include<iostream>#include<fstream>#include<queue>using namespace std;int f,p,c,m;struct e{ int data; int cost; e *next;};e edge[501];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; e *q=new e; q->data=s; q->cost=w 阅读全文

posted @ 2011-05-31 10:36 宇宙吾心 阅读(237) 评论(0) 推荐(0)

poj 2472
摘要:#include<iostream>#include<fstream>#include<queue>#include<cmath>using namespace std;struct e{ int data; double w; e *next;};e edge[101];int n,m;double d[101];int v[101];void solve(){ int i,j,k; queue<int> q; for(i=1;i<=n;i++) d[i]=-10000000; d[1]=0; q.push(1); v[1]= 阅读全文

posted @ 2011-05-31 10:34 宇宙吾心 阅读(237) 评论(0) 推荐(0)

poj 2485
摘要:#include<iostream>#include<fstream>using namespace std;int n;int f[501];int rank[501];struct e{ int s,t,w;};e edge[250001];void init(){ for(int i=1;i<=n;i++) { f[i]=i; rank[i]=0; }}int top;void add(int s,int t,int w){ edge[++top].s=s; edge[top].t=t; edge[top].w=w;}int cmp(const void * 阅读全文

posted @ 2011-05-31 10:32 宇宙吾心 阅读(272) 评论(0) 推荐(0)

poj 2570
摘要:#include<iostream>#include<fstream>using namespace std;int n;int map[201][201];void read(){// ifstream cin("in.txt"); int i,j,k; char c[30]; while(cin>>n) { if(n==0) return; memset(map,0,sizeof(map)); while(cin>>i>>j) { if(i==0&&j==0) break; cin>> 阅读全文

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

poj 2457
摘要:#include<iostream>#include<fstream>#include<queue>using namespace std;struct e{ int data; e *next;};e edge[50001];void add(int s,int t){ e *p=new e; p->data=t; p->next=edge[s].next; edge[s].next=p;}int path[50001];int v[50001];int n,m;int solve(){ int i,j,k; queue<int> 阅读全文

posted @ 2011-05-31 10:30 宇宙吾心 阅读(209) 评论(0) 推荐(0)

poj 2135
摘要:#include<iostream>#include<fstream>#include<queue>using namespace std;struct e{ int data; int c,f; int w; e *next; e *opt;};e edge[1010];int total;int n,m;void add(int s,int t,int h,int w){ e *p=new e; p->data=t; p->c=h; p->f=0; p->w=w; p->next=edge[s].next; edge[s]. 阅读全文

posted @ 2011-05-31 10:29 宇宙吾心 阅读(238) 评论(0) 推荐(0)

poj 2584
摘要:#include<iostream>#include<fstream>#include<queue>using namespace std;struct e{ int data; int c,f; e *next; e *opt;};e edge[40];int n,m,total;int x[40],y[40];int mark[300];void add(int s,int t,int w){ e *p=new e; p->data=t; p->c=w; p->f=0; p->next=edge[s].next; edge[s]. 阅读全文

posted @ 2011-05-30 18:01 宇宙吾心 阅读(245) 评论(0) 推荐(0)

poj 2724
摘要:#include<iostream>#include<fstream>using namespace std;int n,m;int v[2000];int a[2][2000];int map[520][520];int link[520];int vis[520];int dfs(int s){ int i; for(i=1;i<=m;i++) if(vis[i]==0&&map[s][i]) { vis[i]=1; if(link[i]==-1||dfs(link[i])) { link[i]=s; return 1; } } return 阅读全文

posted @ 2011-05-30 11:21 宇宙吾心 阅读(189) 评论(0) 推荐(0)

poj 2949
摘要:#include<iostream>#include<fstream>using namespace std;int n;struct e{ int s,t; double w;};e edge[100001];char c[1002];int mid;int top;void add(int s,int t,int w){ edge[++top].s=s; edge[top].t=t; edge[top].w=w;}double d[27*27];int solve(){ int i,j,k; for(i=1;i<=26*26;i++) d[i]=-100000 阅读全文

posted @ 2011-05-30 11:10 宇宙吾心 阅读(394) 评论(0) 推荐(0)

poj 3160
摘要:#include<iostream>#include<fstream>using namespace std;struct e{ int data; e *next;};e edge[30001],edge1[30001];int n,m;void add(int s,int t){ e *p=new e; p->data=t; p->next=edge[s].next; edge[s].next=p;}int v[30001],dfn[30001],low[30001],top,scc[30001],sta[30001];int total;int ind 阅读全文

posted @ 2011-05-30 10:33 宇宙吾心 阅读(402) 评论(0) 推荐(0)

poj 3228
摘要:#include<iostream>#include<fstream>using namespace std;int n,m,ans;struct e{ int s,t,w;};e edge[40001];int f[401];int cmp(const void *a,const void *b){ return (*(e*)a).w-(*(e*)b).w;}int father(int s){ if(s!=f[s]) f[s]=father(f[s]); return f[s];}int a[401];void unionset(int s,int t){ int 阅读全文

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

poj 3255
摘要:#include<iostream>#include<fstream>#include<queue>using namespace std;struct e{ int data; int cost; e *next;};e edge[5001];struct node{ int data; int kind; int weight; friend bool operator <(node a,node b){ return a.weight>b.weight; }};int n,m;void add(int s,int t,int w){ e * 阅读全文

posted @ 2011-05-29 18:27 宇宙吾心 阅读(294) 评论(0) 推荐(0)

poj 3275
摘要:#include<iostream>#include<fstream>using namespace std;int n,m;int a[1001][1001];int b[1001][1001];int map[1001][1001];void read(){// ifstream cin("in.txt"); int i,j,k,s,t; cin>>n>>m; for(i=1;i<=m;i++) { cin>>j>>k; a[++a[0][j]][j]=k; b[++b[0][k]][k]=j 阅读全文

posted @ 2011-05-29 18:26 宇宙吾心 阅读(218) 评论(0) 推荐(0)

poj 3594
摘要:#include<iostream>#include<fstream>#include<queue>using namespace std;struct e{ int data; int b,h,c; e *next;};e edge[101];int n,m;int start,end;int d[10001][101];struct node{ int time; int weight; int data; friend bool operator <(node a,node b){ return a.weight>b.weight; }}; 阅读全文

posted @ 2011-05-29 11:19 宇宙吾心 阅读(254) 评论(0) 推荐(0)

poj 3281
摘要:#include<iostream>#include<fstream>#include<queue>using namespace std;int n,f,d;struct e{ int data; int c,f; e *next; e *opt;};e edge[500];int total;int h[500];int build(){ int i,j,k; memset(h,0,sizeof(h)); queue<int> q; q.push(0); h[0]=1; while(!q.empty()) { i=q.front(); q.p 阅读全文

posted @ 2011-05-29 10:47 宇宙吾心 阅读(344) 评论(0) 推荐(0)

poj 3310
摘要:#include<iostream>#include<fstream>using namespace std;int n,m;struct e{ int data; e *next;};e edge[101];void add(int s,int t){ e *p=new e; p->data=t; p->next=edge[s].next; edge[s].next=p; e *q=new e; q->data=s; q->next=edge[t].next; edge[t].next=q;}int in[101];int v[101];int 阅读全文

posted @ 2011-05-29 10:46 宇宙吾心 阅读(243) 评论(0) 推荐(0)

poj 3311
摘要:#include<iostream>#include<fstream>using namespace std;int n;int map[14][14];int a[14];int ans;void solve(int s,int t){ int i,j,k; if(ans!=-1&&t>ans) return; if(s==n) { if(ans==-1) ans=t+map[a[s]][0]; else ans=min(ans,t+map[a[s]][0]); return; } for(i=s+1;i<=n;i++) { swap(a[ 阅读全文

posted @ 2011-05-29 10:45 宇宙吾心 阅读(296) 评论(0) 推荐(0)

上一页 1 2 3 下一页

导航