2011年5月29日

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 宇宙吾心 阅读(252) 评论(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)

poj 3328

摘要: #include<iostream>#include<fstream>#include<queue>using namespace std;int n,m;int map[61][31];int sx[61],sy[31];int end[61][31];int top;int d[2][61][31];struct node{ int s,t; int kind; int weight; friend bool operator <(node a,node b){ return a.weight>b.weight; }};int v[2][61 阅读全文

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

导航