結果

問題 No.397 NO MORE KADOMATSU
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-07-15 22:42:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 1,073 bytes
コンパイル時間 1,639 ms
コンパイル使用メモリ 169,556 KB
実行使用メモリ 24,240 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:13:32
合計ジャッジ時間 3,355 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,628 KB
testcase_01 AC 23 ms
23,580 KB
testcase_02 AC 23 ms
24,048 KB
testcase_03 AC 25 ms
23,424 KB
testcase_04 AC 22 ms
23,628 KB
testcase_05 AC 24 ms
23,808 KB
testcase_06 AC 27 ms
23,808 KB
testcase_07 AC 28 ms
24,240 KB
testcase_08 AC 24 ms
23,988 KB
testcase_09 AC 24 ms
23,448 KB
testcase_10 AC 52 ms
23,796 KB
testcase_11 AC 22 ms
24,000 KB
testcase_12 AC 32 ms
23,988 KB
testcase_13 AC 36 ms
23,436 KB
testcase_14 AC 35 ms
23,448 KB
testcase_15 AC 34 ms
23,664 KB
testcase_16 AC 23 ms
24,060 KB
testcase_17 AC 23 ms
23,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    cin >> n;
    V a(n);
    rep(i, n) cin >> a[i];

    int m = 0;
    vector<Pii> v;
    rep(k, n) {
        rep(i, n - 1) {
            if (a[i] > a[i + 1]) {
                v.emplace_back(i, i + 1);
                swap(a[i], a[i + 1]);
                ++m;
            }
        }
    }

    cout << m << endl;
    for (auto&& p : v) {
        cout << p.first << " " << p.second << endl;
    }

    int d;
    cin >> d;
}
0