| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 38416 | wxy | 【J】T1 | C++ | 解答错误 | 0 | 31 MS | 1760 KB | 558 | 2025-10-07 13:49:17 |
#include<bits/stdc++.h> using namespace std; const int N=2e5+5; int n,a[N],t[N],ans[N][2]; int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); t[a[i]]=i; } int cnt=0; for(int i=1;i<=n;i++){ if(a[i]==i) continue; cnt++; ans[cnt][0]=i; ans[cnt][1]=t[i]; swap(a[t[i]],a[i]); swap(t[i],t[a[i]]); } printf("%d\n",cnt); for(int i=1;i<=cnt;i++){ printf("%d %d\n",ans[i][0],ans[i][1]); } return 0; }