fork download
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4. int n;
  5. scanf("%d",&n);
  6. while(n!=0){
  7. int *a = new int[n+1];
  8. for(int i=1;i<=n;i++){
  9. scanf("%d",&a[i]);
  10. }
  11. bool cool =true;
  12. for(int i=1;i<=n;i++){
  13. if(a[a[i]]!=i){
  14. cool=false;
  15. printf("not ambiguous\n");
  16. break;
  17. }
  18. }
  19. if(cool)
  20. printf("ambiguous\n");
  21. scanf("%d",&n);
  22. }
  23. return 0;
  24. }
  25.  
Time limit exceeded #stdin #stdout 5s 528384KB
stdin
Standard input is empty
stdout
Standard output is empty