結果
問題 | No.397 NO MORE KADOMATSU |
ユーザー |
![]() |
提出日時 | 2016-07-15 22:52:13 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 775 bytes |
コンパイル時間 | 1,396 ms |
コンパイル使用メモリ | 161,904 KB |
実行使用メモリ | 25,220 KB |
平均クエリ数 | 936.56 |
最終ジャッジ日時 | 2024-07-17 00:05:17 |
合計ジャッジ時間 | 3,186 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> #define rep(i, a, n) for(int i = a; i < n; i++) #define repp(i, n) rep(i, 0, n) #define repb(i, a, b) for(int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define int long long using namespace std; typedef pair<int, int> P; signed main(){ int n, dm; cin >> n; vector<int> a(n); rep(i, 0, n) cin >> a[i]; vector<int> ans; rep(i, 0, n - 1){ repb(j, n - 1, i + 1){ if(a[j] < a[j - 1]){ ans. push_back(j); ans. push_back(j - 1); swap(a[j], a[j - 1]); } } } cout << ans.size() / 2 << endl; rep(i, 0, ans.size() / 2){ cout << ans[2 * i] << ' ' << ans[2 * i + 1] << endl; } cout.flush(); cin >> dm; }