fork download
  1. #include<stdio.h>
  2. int t;int a[100000],b[100000];int i=0,count=0; int tcopy,j,flag=0;
  3. int main()
  4. {
  5. scanf("%d",&t);
  6. while(t!=0)
  7. {tcopy=t;count= 0;
  8. while(t)
  9. {scanf("%d",&a[i]);
  10. t--;i++;
  11. }
  12.  
  13. for(j=0;j<tcopy;j++)
  14. {
  15. b[a[j]-1]=j+1;
  16.  
  17. }
  18.  
  19.  
  20.  
  21.  
  22. for(i=0;i<tcopy;i++)
  23. {
  24.  
  25. if(a[i]!=b[i])
  26. {flag=1;
  27. break;}
  28.  
  29. }
  30. if(flag==1)
  31. printf("not ambiguous\n");
  32. else
  33. printf("ambiguous\n");
  34.  
  35.  
  36. scanf("%d",&t);fflush(stdin);
  37.  
  38. }
  39.  
  40. return 0;
  41. }
  42.  
Success #stdin #stdout 0s 10208KB
stdin
4
1 4 3 2
1
1
0
stdout
ambiguous
ambiguous