Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include<bits/stdc++.h>using namespace std;struct node{int f;node* link;}root[1010];int N,K;void findFather(int x){node* temp=root[x].link;while(temp!=NULL){if(root[temp->f].f<0){root[temp->f].f=x;findFather(temp->f);}temp=temp->link;}return;}int main(){ios::sync_with_stdio(false);int i,j,k,l;node* temp;while(cin>>N>>K){for(i=1;i<=N;i++){root[i].f=-1;root[i].link=NULL;}root[K].f=0;