ambiguous permutation is showing wrong answer, can u tell what is wrong in this code

#include<stdio.h>
#define MAX 100000
int main()
{
int n,i,a[MAX],b[MAX];
scanf("%d",&n);
while(n>=1&&n<=100000)
{
int c=0;
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
b[(a[i])]=i;
}
for(i=1;i<=n;i++)
if(a[i]!=b[i])
{
c++;
break;
}
if(c==0)
printf(“ambiguous\n”);
else
printf(“non-ambiguous\n”);
scanf("%d",&n);
}
return 0;
}

Check the output format

ambiguous
not ambiguous

Your code prints non-ambiguous which is different from correct output format…

You can take a look at AC version of your code after modifications:
http://www.codechef.com/viewsolution/5615370
:slight_smile: