Created
March 14, 2015 04:40
-
-
Save shohan4556/3102bdb03acb47255457 to your computer and use it in GitHub Desktop.
Codechef -- Ambiguous Permutations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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