結果

問題 No.397 NO MORE KADOMATSU
ユーザー treeonetreeone
提出日時 2016-07-15 22:52:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 775 bytes
コンパイル時間 1,290 ms
コンパイル使用メモリ 147,920 KB
実行使用メモリ 24,444 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:14:57
合計ジャッジ時間 3,000 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,664 KB
testcase_01 AC 24 ms
23,508 KB
testcase_02 AC 24 ms
24,324 KB
testcase_03 AC 26 ms
23,640 KB
testcase_04 AC 25 ms
23,388 KB
testcase_05 AC 26 ms
23,520 KB
testcase_06 AC 28 ms
23,688 KB
testcase_07 AC 30 ms
23,628 KB
testcase_08 AC 25 ms
24,444 KB
testcase_09 AC 23 ms
24,396 KB
testcase_10 AC 52 ms
24,312 KB
testcase_11 AC 23 ms
23,808 KB
testcase_12 AC 33 ms
24,384 KB
testcase_13 AC 38 ms
23,700 KB
testcase_14 AC 40 ms
24,048 KB
testcase_15 AC 39 ms
23,388 KB
testcase_16 AC 24 ms
23,340 KB
testcase_17 AC 23 ms
23,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0