1 #include<iostream> 2 #include<stdio.h> 3 #include<vector> 4 using namespace std; 5 6 int main() 7 { 8 //freopen("acm.acm","r",stdin); 9 vector<int> coll; 10 int num; 11 int a; 12 int i; 13 bool * boo; 14 while(1) 15 { 16 scanf("%d",&num); 17 if(num == 0) 18 break; 19 boo = new bool[num]; 20 memset(boo,false,sizeof(bool)*num); 21 for(i = 0; i < num; ++ i) 22 { 23 scanf("%d",&a); 24 coll.push_back(a); 25 } 26 for(i = 0; i < num; ++ i) 27 { 28 if(boo[i]) 29 { 30 continue; 31 } 32 else 33 { 34 if(coll[coll[i] - 1] != i +1) 35 { 36 cout<<"not ambiguous"<<endl; 37 break; 38 } 39 else 40 { 41 boo[coll[i] - 1] = true; 42 //boo[i] = true; 43 } 44 45 } 46 47 } 48 if(i == num) 49 { 50 cout<<"ambiguous"<<endl; 51 } 52 delete[] boo; 53 coll.clear(); 54 } 55 }