G - A Bug's Life(带权并查集模板题)
#include
using namespace std;
int f[4000];int r[4000];int flag;
int find(int x){
if(x==f[x]) return x;
int z=f[x];
f[x]=find(f[x]);
f[z]=f[x];
r[x]=(r[x]+r[z])%2;
return f[x];
}
void uni(int a,int b){...
原创
2019-03-26 20:03:24 ·
146 阅读 ·
0 评论