結果

問題 No.397 NO MORE KADOMATSU
ユーザー tubo28tubo28
提出日時 2016-07-16 17:29:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,419 bytes
コンパイル時間 1,013 ms
コンパイル使用メモリ 115,216 KB
実行使用メモリ 35,472 KB
最終ジャッジ日時 2023-09-24 00:21:35
合計ジャッジ時間 7,536 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
権限があれば一括ダウンロードができます

ソースコード

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];
        }
        int t;
        cin >> t;
        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;
    }
}
0