poj2470
2017-02-10 09:16
218 查看
题目大意:
给N个数字,从1到N,然后按照字面的顺序重新排列。例如:2 3 4 5 1
[1] [2] [3] [4] [5]
–>
5 1 2 3 4
[1] [2] [3] [4] [5]
判断新旧顺序是否一样
解题思路:
转换一下,进行比较即可代码如下:
#include<iostream> using namespace std; int main() { int n; while(scanf("%d",&n)&&n) { int num[100010]; int sto[100010]; memset(num,0,sizeof(num)); memset(sto,0,sizeof(sto)); for(int i=1;i<=n;i++) { scanf("%d",&num[i]); sto[num[i]]=i; } int flag=0; for(int i=1;i<=n;i++) { if(sto[i]!=num[i]) { printf("not ambiguous\n"); flag=1; break; } } if(!flag) printf("ambiguous\n"); } return 0; }
相关文章推荐
- poj 2470 Ambiguous permutations
- POJ 2470
- poj 2470 Ambiguous permutations
- poj 2470 Ambiguous permutations
- POJ 2470 Ambiguous permutations(简单题 理解题意)
- poj 2470 Ambiguous permutations
- POJ 2470 Ambiguous permutations(简单题 理解题意)
- POJ 2470 Ambiguous permutation(我的水题之路——位置和值的队列)
- POJ 2470 Relatives (欧拉函数)
- poj2470
- poj 2470 Ambiguous permutations
- POJ 2470 || SDUT 2356 Ambiguous permutations(简单规律)
- POJ 2470 Ambiguous permutations G++
- POJ-2470(用例过了,但一直超时,难道是Java效率太低?)
- POJ 2470 Ambiguous permutations(水~)
- Nearest Common Ancestors--POJ 1330
- POJ_2828 Buy Ticket(线段树)
- POJ 2823 Sliding Window【单调队列】
- POJ 1062 昂贵的聘礼
- POJ 1318 Word Amalgamation