結果

問題 No.397 NO MORE KADOMATSU
ユーザー dnishdnish
提出日時 2018-06-17 15:22:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 714 bytes
コンパイル時間 2,131 ms
コンパイル使用メモリ 167,244 KB
実行使用メモリ 24,276 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 01:48:17
合計ジャッジ時間 3,254 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,520 KB
testcase_01 AC 22 ms
23,376 KB
testcase_02 AC 21 ms
24,168 KB
testcase_03 AC 23 ms
24,216 KB
testcase_04 AC 23 ms
24,252 KB
testcase_05 AC 23 ms
24,228 KB
testcase_06 AC 26 ms
23,412 KB
testcase_07 AC 27 ms
23,892 KB
testcase_08 AC 22 ms
24,180 KB
testcase_09 AC 22 ms
24,048 KB
testcase_10 AC 48 ms
23,664 KB
testcase_11 AC 23 ms
23,652 KB
testcase_12 AC 34 ms
23,244 KB
testcase_13 AC 35 ms
23,856 KB
testcase_14 AC 33 ms
24,240 KB
testcase_15 AC 32 ms
24,276 KB
testcase_16 AC 22 ms
23,388 KB
testcase_17 AC 21 ms
24,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define REP(i,n,N) for(int i=(n); i<(N); i++)
#define RREP(i,n,N) for(ll i=(N-1); i>=n; i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll inf=1e18;

int N;
int a[110];
vector<pair<int,int>> vt;
int main(){
    cin>>N;
    REP(i,0,N){
        cin>>a[i];
    }
    REP(i,0,N){
        REP(j,1,N){
            if(a[j-1]>a[j]){
                vt.emplace_back(j-1,j);
                swap(a[j-1],a[j]);
            }
        }
    }
    p(vt.size());
    for(auto v:vt){
        p2(v.first, v.second);
    }
    cin>>a[101];
    return 0;
}
0