結果
問題 | No.326 あみだますたー |
ユーザー |
|
提出日時 | 2022-12-22 18:30:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 787 bytes |
コンパイル時間 | 1,365 ms |
コンパイル使用メモリ | 173,516 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-18 03:23:23 |
合計ジャッジ時間 | 4,540 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | AC * 7 WA * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, k, v; cin >> n >> k; vector<int> a(n), pos; iota(a.begin(), a.end(), 0); pos = a; for(int i = 0, l, r; i < k; i++){ cin >> l >> r; swap(a[--l], a[--r]); pos[a[l]] = l; pos[a[r]] = r; } for(int i = 0; i < n; i++){ cin >> v; a[pos[--v]] = i; } vector<pair<int,int>> ans; for(int i = 0; i < n; i++){ for(int j = n - 1; j > i; j--){ if(a[j] < a[j - 1]){ swap(a[j], a[j - 1]); ans.emplace_back(j, j + 1); } } } cout << ans.size() << '\n'; for(auto &&p:ans)cout << p.first << " " << p.second << '\n'; }