PERMUT2 - Ambiguous Permutations
#include <iostream>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
const int maxSize = 100001;
int arr[maxSize];
int a[maxSize];
int main()
{
int n, pos;
bool flag;
while(true)
{
cin >> n;
if(n == 0)
break;
pos = 1;
flag = true;
REP(i, n)
{
cin >> arr[i];
a[arr[i] - 1] = pos;
pos++;
}
REP(i, n)
{
if(a[i] != arr[i])
{
flag = false;
break;
}
}
if(!flag)
{
cout << "not ambiguous\n";
}
else
{
cout << "ambiguous\n";
}
}
return 0;
}
Comments
Post a Comment