why wrong answer?

#include<stdio.h>

int main()
{
int n,a[100001],i,t;
scanf("%d",&t);
while(t–)
{
scanf("%d",&n);
for(i=1;i<=n;i++)

     scanf("%d",&a[i]);
for(i=1;i<=n;i++)
{
	if(a[a[i]]!=i)
	{
		printf("not ambiguous \n");
		break;
	}
	if(i==n)
		printf("ambiguous \n");
   }
}
return 0;

}

Take a look at input format again.
Your algorithm is fine, but reading input is bugged.

wrong input method

on this problem my problem is evaluated as wrong answer.
can you pls help!
#include
using namespace std;
int main()
{
int a[5],i;
for(i=0;i<5;i++)
{
cin>>a[i];
}
cout<<endl;
for(i=0;i<5;i++)
{
if(a[i]==42)
break;
cout<<a[i]<<endl;
}
}

//