poj2470

简单题

View Code
#include <iostream>
#include
<cstdio>
#include
<cstdlib>
#include
<cstring>
using namespace std;

#define maxn 100005

int f[maxn], pos[maxn];

int main()
{
//freopen("t.txt", "r", stdin);
int n;
while (scanf("%d", &n), n != 0)
{
for (int i = 1; i <= n; i++)
{
scanf(
"%d", &f[i]);
pos[f[i]]
= i;
}
bool am = true;
for (int i = 1; i <= n; i++)
if (f[i] != pos[i])
{
am
= false;
break;
}
if (!am)
printf(
"not ambiguous\n");
else
printf(
"ambiguous\n");
}
return 0;
}

posted @ 2011-05-22 10:28  金海峰  阅读(236)  评论(0编辑  收藏  举报