pku 1674 Sorting by Swapping
2009-04-24 10:29
537 查看
#include <iostream> #include <climits> #include <algorithm> using namespace std; int map[10005]; int main() { int N, n; scanf("%d", &N); while(N--) { scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%d", &map[i]); int cnt = 0; for(int i = 1; i < n; ++i) if(map[i] != i) { swap(map[i], *(find(map+i+1, map+n+1, i))); cnt++; } printf("%d/n", cnt); } return 0; }
相关文章推荐
- pku1674 Sorting by Swapping
- pku1674 Sorting by Swapping
- pku_1674 Sorting by Swapping 解题报告
- PKU 1674 Sorting by Swapping
- [数学题] Sorting by Swapping pku 1674
- poj 1674 Sorting by Swapping
- [POJ 1674] Sorting by Swapping
- POJ 1674 Sorting by Swapping(需…
- poj 1674 Sorting by Swapping
- poj 1674 Sorting by Swapping
- poj 1674 Sorting by Swapping 置换群
- POJ-1674 Sorting by Swapping 置换群
- poj 1674 Sorting by Swapping(数字置换环)
- POJ 1674 Sorting by Swapping 笔记
- poj 1674 Sorting by Swapping
- Sorting by Swapping
- Sorting by Swapping
- Sorting a Hashtable by Values
- Python sorting list of dictionaries by multiple keys
- Sorting by Subsequences CodeForces - 844C