ambiguous pemutation :wrong answer

as im submitting the code below its showing a wrong answer

/*created by raghavyadavm*/

#include<stdio.h>

int main()
{
int n,i,j,flag=0;
unsigned int a[100001],b[100001];

do
{
	scanf("%d",&n);
	flag=0;

	if(n)
	{
		for(i=1;i<=n;i++)            //reading and storing
		{
			scanf("%d",&a[i]);
			b[a[i]]=i;

		}

		for(i=1;i<=n;i++)
		{
			if(a[i]==b[i])
				flag++;      //comparing

		}

		if(flag==n)
			printf("ambiguous\n");
		else
			printf("unambiguous\n");

	}

}while(n);


return 0;

}

From the above given i think your LOGIC is correct. But when i read the question i found that the answer should be “not ambiguous” without quotes. Try that. If not please do tell :slight_smile:

//