摘要: http://poj.org/problem?id=2485求最小生成树中最长的那个边 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #define INF 0x0fffffff 5 int N,T; 6 int mat[502][502]; 7 int prim() 8 { 9 int start=0;10 bool visited[502]={false};11 int nearest[502];12 int max_len=-1;13 int min,pos;1.. 阅读全文
posted @ 2013-03-01 20:20 linyvxiang 阅读(159) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1789 1 #include <string.h> 2 #include <stdio.h> 3 #include <stdlib.h> 4 #define INF 0x0fffffff 5 int mat[2002][2002]; 6 int N; 7 typedef struct Code { 8 char str[10]; 9 }Code;10 Code codes[2002];11 int calc(char *str1,char *str2)12 {13 char *p=str1,*q=str2 阅读全文
posted @ 2013-03-01 19:57 linyvxiang 阅读(214) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3278BFS 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <queue> 5 using namespace std; 6 int N,K; 7 bool visited_flag[100002]={false}; 8 bool check(int x) 9 {10 if(0<=x&&x<=100000)11 return true;12 return fal 阅读全文
posted @ 2013-03-01 14:34 linyvxiang 阅读(223) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1611简单并查集 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 int father[32002]; 5 void init(int n) 6 { 7 int i; 8 for(i=0;i<=n;i++) 9 father[i]=i;10 }11 int find_father(int child)12 {13 if(father[child]==child)14 return child;15 ... 阅读全文
posted @ 2013-03-01 09:24 linyvxiang 阅读(200) 评论(0) 推荐(0) 编辑