結果

問題 No.397 NO MORE KADOMATSU
ユーザー tubo28tubo28
提出日時 2016-07-16 17:30:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,422 bytes
コンパイル時間 1,038 ms
コンパイル使用メモリ 115,480 KB
実行使用メモリ 24,288 KB
平均クエリ数 36.83
最終ジャッジ日時 2023-09-24 00:21:27
合計ジャッジ時間 2,276 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,976 KB
testcase_01 AC 19 ms
23,532 KB
testcase_02 AC 20 ms
23,652 KB
testcase_03 AC 20 ms
23,388 KB
testcase_04 AC 19 ms
23,976 KB
testcase_05 AC 19 ms
23,652 KB
testcase_06 AC 19 ms
23,604 KB
testcase_07 AC 20 ms
23,664 KB
testcase_08 AC 20 ms
23,940 KB
testcase_09 AC 20 ms
23,940 KB
testcase_10 AC 19 ms
24,276 KB
testcase_11 AC 19 ms
24,288 KB
testcase_12 AC 20 ms
24,000 KB
testcase_13 AC 20 ms
23,580 KB
testcase_14 AC 22 ms
23,376 KB
testcase_15 AC 19 ms
24,036 KB
testcase_16 AC 20 ms
23,496 KB
testcase_17 AC 20 ms
23,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,k) for (int i = 0; i < (int)(k); i++)
#define all(c) begin(c), end(c)

int main() {
    int n;
    while (cin >> n) {
        vector<int> a(n);
        for (size_t i = 0; i < n; i++) {
            cin >> a[i];
        }

        vector<pair<int, int>> ans;
        for (size_t i = 0; i < n; i++) {
            int x = min_element(a.begin() + i, a.end()) - a.begin();
            if (x != i) {
                ans.emplace_back(x, i);
                swap(a[i], a[x]);
            }
        }
        cout << ans.size() << endl;
        for (size_t i = 0; i < ans.size(); i++) {
            cout << ans[i].first << ' ' << ans[i].second << endl;
        }

        cout << flush;

        int t;
        cin >> t;
    }
}
0