結果
問題 |
No.326 あみだますたー
|
ユーザー |
|
提出日時 | 2016-05-07 12:23:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 622 bytes |
コンパイル時間 | 525 ms |
コンパイル使用メモリ | 61,684 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 00:16:10 |
合計ジャッジ時間 | 1,636 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 |
ソースコード
#include <iostream> #include <vector> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> l(n); for (int i = 0; i < n; i++) l[i] = i; for (int i = 0; i < k; i++) { int x, y; cin >> x >> y; swap(l[x - 1], l[y - 1]); } vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> result; for (int i = 0; i < n; i++) { for (int j = 0; j + 1 < n - i; j++) { if (a[l[j]] > a[l[j + 1]]) { result.emplace_back(j + 1); swap(l[j], l[j + 1]); } } } cout << result.size() << endl; for (auto no : result) cout << no << " " << no + 1 << endl; return 0; }