結果
問題 | No.397 NO MORE KADOMATSU |
ユーザー |
|
提出日時 | 2016-07-15 22:45:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 672 bytes |
コンパイル時間 | 1,614 ms |
コンパイル使用メモリ | 173,528 KB |
実行使用メモリ | 25,220 KB |
平均クエリ数 | 936.56 |
最終ジャッジ日時 | 2024-07-17 00:04:19 |
合計ジャッジ時間 | 3,222 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<P> ans; for (int i = 0; i < n - 1; i++) { for (int j = n - 1; j > i; j--) { if (a[j - 1] > a[j]) { ans.emplace_back(j - 1, j); swap(a[j - 1], a[j]); } } } int s = ans.size(); cout << s << endl; for (int i = 0; i < s; i++) { cout << ans[i].first << " " << ans[i].second << endl; } int dummy; cin >> dummy; return 0; }