Skip to content

Instantly share code, notes, and snippets.

@shohan4556
Created March 14, 2015 04:40
Show Gist options
  • Save shohan4556/3102bdb03acb47255457 to your computer and use it in GitHub Desktop.
Save shohan4556/3102bdb03acb47255457 to your computer and use it in GitHub Desktop.
Codechef -- Ambiguous Permutations
#include<stdio.h>
int ara[1000005];
int invara[1000005];
int main()
{
int n,i,count;
while(scanf("%d",&n)==1){
count=0;
if(n==0)
break;
for(i=1;i<=n;i++){
scanf("%d",&ara[i]);
invara[ara[i]]=i;
}
for(i=1;i<=n;i++){
if(ara[i]==invara[i])
count++;
}
if(count==n)
printf("ambiguous\n");
else
printf("not ambiguous\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment