本文共 655 字,大约阅读时间需要 2 分钟。
题目传送门:
AC代码
#include #include #include #include #include #include #include #include using namespace std;struct Node{ int id,level; Node * parent; Node(int x):id(x),parent(NULL){};};int main(){ int n,m; scanf("%d %d",&n,&m); vector ans; for (int i=0; i parent = ans[curid-1]; } } map res; for(int i=0;i parent) { curCount++; p = p->parent; } ans[i]->level = curCount; res[curCount]++; } int targetID = 0,targetNum = 0; for (auto it = res.begin();it!=res.end();++it) { if(it->second>targetNum) { targetNum = it->second; targetID = it->first; } } printf("%d %d\n",targetNum,targetID); return 0;}
转载地址:http://yqhji.baihongyu.com/