結果

問題 No.397 NO MORE KADOMATSU
ユーザー latte0119latte0119
提出日時 2016-07-16 16:16:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,081 bytes
コンパイル時間 881 ms
コンパイル使用メモリ 70,712 KB
実行使用メモリ 24,408 KB
平均クエリ数 36.83
最終ジャッジ日時 2023-09-24 00:21:18
合計ジャッジ時間 1,951 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
24,264 KB
testcase_01 AC 18 ms
23,352 KB
testcase_02 AC 19 ms
23,352 KB
testcase_03 AC 19 ms
24,168 KB
testcase_04 AC 20 ms
23,340 KB
testcase_05 AC 21 ms
23,316 KB
testcase_06 AC 21 ms
24,336 KB
testcase_07 AC 19 ms
23,520 KB
testcase_08 AC 19 ms
23,664 KB
testcase_09 AC 18 ms
23,352 KB
testcase_10 AC 19 ms
24,264 KB
testcase_11 AC 20 ms
23,796 KB
testcase_12 AC 20 ms
23,604 KB
testcase_13 AC 19 ms
23,376 KB
testcase_14 AC 19 ms
24,408 KB
testcase_15 AC 19 ms
23,532 KB
testcase_16 AC 22 ms
23,604 KB
testcase_17 AC 20 ms
23,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cstring>
#include<cstdlib>
#include<string>
#include<numeric>
using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

bool f(int a,int b,int c){
    if(a==b||b==c||c==a)return false;
    if(a>b&&c>b)return true;
    if(a<b&&c<b)return true;
    return false;
}

signed main(){
    int N;
    int A[100];
    cin>>N;
    rep(i,N)cin>>A[i];
    vpint ans;
    rep(i,N){
        int idx=i;
        for(int j=i+1;j<N;j++)if(A[idx]>A[j])idx=j;
        if(idx==i)continue;
        ans.pb(pint(i,idx));
        swap(A[i],A[idx]);
    }
    cout<<ans.size()<<endl;
    rep(i,ans.size())cout<<ans[i].first<<" "<<ans[i].second<<endl;
    int tmp;cin>>tmp;
    return 0;
}
0