ZOJ 2795 Ambiguous permutations(序列的置换)

来源:互联网 发布:2017软件行业寒冬 编辑:程序博客网 时间:2024/06/02 19:28

原题:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1795

//输入的数组 5 1 2 3 4
//对应的下标 1 2 3 4 5
//置换的序列 2 3 4 5 1(意思给就是给 【下标】 排序 啦)
//弄2个数组,一个放原序列,另一个放置换的序列
#include<iostream>using namespace std;int a[100001];int b[100001];int main(){int n,tmp,flag;while(cin>>n && n!=0){flag=1;for(int i=1;i<=n;i++){cin>>tmp;a[i]=tmp;b[tmp]=i;}for(int i=1;i<=n;i++){if(a[i]!=b[i]){flag=0;break;}}if(flag) cout<<"ambiguous"<<endl;else cout<<"not ambiguous"<<endl;}}


0 0
原创粉丝点击