第1行输入N,之后一行一个整数表示牛棚i的后继牛棚Xi,共N行.
4 //有四个点
1 //1有一条边指向1
3 //2有一条边指向3
2 //3有一条边指向2
3
INPUT DETAILS:
Four stalls.
* Stall 1 directs the cow back to stall 1.
* Stall 2 directs the cow to stall 3
* Stall 3 directs the cow to stall 2
* Stall 4 directs the cow to stall 3
1
2
2
3
//Cow 1: Start at 1, next is 1. Total stalls visited: 1.
Cow 2: Start at 2, next is 3, next is 2. Total stalls visited: 2.
Cow 3: Start at 3, next is 2, next is 3. Total stalls visited: 2.
Cow 4: Start at 4, next is 3, next is 2, next is 3. Total stalls visited: 3.