結果

問題 No.397 NO MORE KADOMATSU
ユーザー purple_jwlpurple_jwl
提出日時 2016-07-15 22:50:13
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,081 bytes
コンパイル時間 1,315 ms
コンパイル使用メモリ 148,668 KB
実行使用メモリ 24,504 KB
平均クエリ数 38.72
最終ジャッジ日時 2023-09-23 11:03:40
合計ジャッジ時間 4,347 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,664 KB
testcase_01 WA -
testcase_02 AC 26 ms
23,568 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 25 ms
23,556 KB
testcase_10 WA -
testcase_11 AC 25 ms
24,096 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 25 ms
24,048 KB
testcase_17 AC 24 ms
23,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 29;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep (i, n) cin >> a[i];

    int cnt = 0;
    vector<pair<int, int>> p;
    rep (i, n) {
        int minv = a[i];
        int idx = i;
        REP (j, i + 1, n) {
            if (minv > a[j]) {
                minv = a[j];
                idx = j;
            }
        }
        if (idx != i) {
            cnt++;
            p.eb(mp(i, idx));
        }
    }

    cout << cnt << endl;
    rep (i, sz(p)) {
        cout << p[i].F << ' ' << p[i].S << endl;
    }

    int tmp;
    cin >> tmp;
}
0