摘要:
http://poj.org/problem?id=2524这道题就是并查集。 1 #include 2 #include 3 #include 4 #define maxn 50010 5 using namespace std; 6 int a[maxn]; 7 int n,m; 8 void init() 9 {10 for(int i=1;i<=n;i++)11 a[i]=i;12 }13 int find1(int x)14 {15 if(x!=a[x])16 a[x]=find1(a[x]);17 return a[x];18... 阅读全文
摘要:
http://poj.org/problem?id=2965 1 #include 2 #include 3 #include 4 #define maxn 100000 5 using namespace std; 6 struct node 7 { 8 int r,c,pre,ans,mm; 9 }p[maxn],st,st1;10 int id;11 int flag;12 bool visi[maxn];13 char ss[maxn];14 void bfs(int m)15 {16 int be=0,ed=0;17 p[ed].c=p[ed].r=p[ed]... 阅读全文