标签:nbut
题目链接:https://ac.2333.moe/Problem/view.xhtml?id=1218
#include<cstdio> #include<iostream> #include<sstream> #include<cstdlib> #include<cstring> #include<string> #include<climits> #include<cmath> #include<algorithm> #include<queue> #include<vector> #include<stack> #include<set> #include<map> using namespace std; int main() { int i,fa[2005]; int n,a,b; while(~scanf("%d",&n)) { for(i=0; i<=2005; i++) fa[i]=i;//先让自己是自己的父亲 while(n--) { scanf("%d%d",&a,&b); fa[a]=b;//b是a的父亲 } int h1,h2; h1=h2=0; int A=1; while(fa[A]!=A) { A=fa[A]; h1++; } int B=2; while(fa[B]!=B) { B=fa[B]; h2++; } if(h1>h2) printf("You are my elder\n"); else if(h1<h2) printf("You are my younger\n"); else printf("You are my brother\n"); } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:nbut
原文地址:http://blog.csdn.net/qq_30076791/article/details/47750555