Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include<iostream>#include<string>#include<string.h>#include<map>using namespace std;const int maxn=100002;struct node{int v,next;}tree[maxn];string name[maxn];int st[maxn];int fa[maxn],height[maxn],f[maxn];int cnt;map<string,int> mapname;void add(int u,int v){tree[cnt].v=v;tree[cnt].next=st[u];st[u]=cnt++;}int find(int x){return f[x]?find(f[x]):x;}