結果

問題 No.397 NO MORE KADOMATSU
ユーザー confconf
提出日時 2016-07-15 22:49:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 541 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 66,192 KB
実行使用メモリ 24,324 KB
平均クエリ数 36.83
最終ジャッジ日時 2023-09-24 00:14:36
合計ジャッジ時間 1,884 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
24,324 KB
testcase_01 AC 20 ms
23,664 KB
testcase_02 AC 19 ms
23,520 KB
testcase_03 AC 20 ms
23,364 KB
testcase_04 AC 20 ms
23,928 KB
testcase_05 AC 19 ms
23,940 KB
testcase_06 AC 19 ms
23,652 KB
testcase_07 AC 21 ms
24,000 KB
testcase_08 AC 20 ms
23,532 KB
testcase_09 AC 20 ms
23,664 KB
testcase_10 AC 19 ms
23,808 KB
testcase_11 AC 19 ms
24,180 KB
testcase_12 AC 20 ms
24,156 KB
testcase_13 AC 20 ms
23,376 KB
testcase_14 AC 20 ms
23,364 KB
testcase_15 AC 20 ms
23,664 KB
testcase_16 AC 22 ms
24,036 KB
testcase_17 AC 19 ms
23,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> V(N);
    vector<pair<int,int>> H;
    for(int i=0;i<N;i++)cin>>V[i];
    for(int i=0;i<N;i++){
        auto m = min_element(V.begin()+i,V.end());
        if(m!=V.begin()+i){
            int j=m-V.begin();
            swap(V[i],V[j]);
            H.emplace_back(i,j);
        }
    }
    cout<<H.size()<<endl;
    for(auto &h:H){
        cout<<h.first<<' '<<h.second<<endl;
    }
    cout<<flush;
    cin>>N;
}
0