結果

問題 No.397 NO MORE KADOMATSU
ユーザー algon_320algon_320
提出日時 2016-07-15 23:09:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 1,014 ms
コンパイル使用メモリ 148,532 KB
実行使用メモリ 24,360 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:16:36
合計ジャッジ時間 2,594 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
23,532 KB
testcase_01 AC 20 ms
24,096 KB
testcase_02 AC 19 ms
23,532 KB
testcase_03 AC 20 ms
24,360 KB
testcase_04 AC 19 ms
23,784 KB
testcase_05 AC 22 ms
23,676 KB
testcase_06 AC 23 ms
23,280 KB
testcase_07 AC 24 ms
23,352 KB
testcase_08 AC 20 ms
24,036 KB
testcase_09 AC 19 ms
23,688 KB
testcase_10 AC 44 ms
23,508 KB
testcase_11 AC 20 ms
23,424 KB
testcase_12 AC 26 ms
23,592 KB
testcase_13 AC 29 ms
24,096 KB
testcase_14 AC 29 ms
23,988 KB
testcase_15 AC 33 ms
24,324 KB
testcase_16 AC 19 ms
23,772 KB
testcase_17 AC 20 ms
23,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);i++)
#define FORE(x,arr) for(auto &x:arr)
#define FOR(i,a,n) for(int i=a;i<(int)(n);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];

    vector<pii> ans;
    REP(j,N){
        FOR(i,1,N) {
            if(A[i-1]>A[i]) {
                ans.push_back(pii(i-1,i));
                swap(A[i-1],A[i]);
            }
        }
    }

    cout << ans.size() << endl;
    FORE(p,ans) cout << p.first << " " << p.second << endl;

    int dummy;
    cin >> dummy;
    return 0;
}
0