Advertisement
shamiul93

BUET ambiguous permutation

Apr 6th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include<stdio.h>
  2. main()
  3. {
  4.     int i , n=1 , test ,flag , tem , tem2 ,num,  a[20000][20] , b[20000] ;
  5.     while(scanf("%d",&n)&&n!=0)
  6.     {
  7.         for(i=0 ; i<n ; i++)
  8.         {
  9.             a[i][1]=i+1;
  10.             scanf("%d",&a[i][2]);
  11.         }
  12.        for(i=0;i<n ; i++)
  13.        {
  14.            tem=a[i][2];
  15.            tem2=tem-1;
  16.            b[tem2]=a[i][1];
  17.        }
  18.        flag=1;
  19.        for(i=0;i<n;i++)
  20.        {
  21.            if(a[i][2]!=b[i])
  22.             {
  23.                 flag=0;
  24.                 break;
  25.             }
  26.        }
  27.        if(flag==1)
  28.         printf("ambiguous\n");
  29.        else
  30.         printf("not ambiguous\n");
  31.     }
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement