結果
| 問題 | No.3775 Distant Swap |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-24 00:39:04 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 12 ms / 2,000 ms |
| + 678µs | |
| コード長 | 552 bytes |
| 記録 | |
| コンパイル時間 | 1,481 ms |
| コンパイル使用メモリ | 219,220 KB |
| 実行使用メモリ | 9,864 KB |
| 最終ジャッジ日時 | 2026-10-24 00:39:11 |
| 合計ジャッジ時間 | 4,538 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,K; cin >> N >> K;
vector<int> P(N);
for(auto &p : P) cin >> p,p--;
vector<pair<int,int>> answer;
for(int t=0; t<N; t++){
for(int i=0; i+K<N; i++) if(P.at(i) > P.at(i+K)) answer.push_back({i,i+K}),swap(P.at(i),P.at(i+K));
}
for(int i=0; i<N; i++) if(P.at(i) != i){cout << "-1\n"; return 0;}
cout << answer.size() << "\n";
for(auto [a,b] : answer) cout << a+1 << " " << b+1 << "\n";
}