Title Link: 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;//First let yourself be your father while (n--) {scanf ("%d%d", &a,&b); Fa[a]=b;//b is A's father} 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;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Nbut 1218 you is my brother