結果

問題 No.397 NO MORE KADOMATSU
コンテスト
ユーザー Aegeaner G
提出日時 2026-09-26 19:26:45
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 844 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,022 ms
コンパイル使用メモリ 355,340 KB
実行使用メモリ 19,976 KB
最終ジャッジ日時 2026-09-26 19:27:01
合計ジャッジ時間 13,757 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

#include <cstdint>
using namespace std;
using ll = int64_t;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& v : a) {
        cin >> v;
    }
    int ans = 0;
    vector<pair<int, int>> ops;
    for (int i = 0; i + 1 < n; i++) {
        int offset = i;
        for (int j = i + 1; j < n; j++) {
            if (a[j] < a[offset]) {
                offset = j;
            }
        }
        if (offset != i) {
            swap(a[i], a[offset]);
            ops.emplace_back(i, offset);
        }
    }
    cout << ops.size() << '\n';
    for (auto& [i, j] : ops) {
        cout << i << " " << j << '\n';
    }

    int dummy;
    cin >> dummy;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;

    while (T--) {
        solve();
    }

    return 0;
}
0