http://www.spoj.com/problems/PERMUT2/
如题。。
#include<cstdio> #include<cstring> int n,i,j; int a[100005]; int main(){ while(scanf("%d",&n)&&n){ for (i=1;i<=n;i++){ scanf("%d",&a[i]); } for (i=1;i<=n;i++){ if (a[a[i]]!=i){printf("not ");break;} } printf("ambiguous\n"); } }
时间: 2024-10-03 13:38:50