西南民族大学第十届校赛(同步赛) D
题目链接:点我转移
1 #include <stdio.h> 2 #define N 5500 3 int a[N]; 4 int main() 5 { 6 int n; 7 scanf("%d", &n); 8 for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); 9 for (int i = 1; i <= n; ++i) 10 { 11 if (a[a[a[i]]] == i) 12 { 13 puts("YES"); 14 return 0; 15 } 16 } 17 puts("NO"); 18 return 0; 19 }