結果

問題 No.397 NO MORE KADOMATSU
ユーザー parukiparuki
提出日時 2016-07-15 22:47:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,051 bytes
コンパイル時間 1,866 ms
コンパイル使用メモリ 168,068 KB
実行使用メモリ 24,432 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:14:33
合計ジャッジ時間 3,279 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
23,436 KB
testcase_01 AC 23 ms
24,180 KB
testcase_02 AC 19 ms
23,364 KB
testcase_03 AC 21 ms
24,048 KB
testcase_04 AC 20 ms
23,868 KB
testcase_05 AC 21 ms
23,376 KB
testcase_06 AC 22 ms
23,880 KB
testcase_07 AC 22 ms
23,568 KB
testcase_08 AC 19 ms
23,460 KB
testcase_09 AC 20 ms
23,700 KB
testcase_10 AC 35 ms
24,348 KB
testcase_11 AC 20 ms
24,432 KB
testcase_12 AC 24 ms
23,700 KB
testcase_13 AC 28 ms
24,096 KB
testcase_14 AC 27 ms
24,096 KB
testcase_15 AC 27 ms
24,288 KB
testcase_16 AC 19 ms
23,664 KB
testcase_17 AC 20 ms
23,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

vector<pii> bubbleSort(vi &v){
    vector<pii> res;
    for(int i = 0; i < (int)v.size(); ++i){
        for(int j = i; j > 0 && v[j - 1] > v[j]; --j){
            swap(v[j - 1], v[j]);
            res.emplace_back(j - 1, j);
        }
    }
    return res;
}

int N, M;

int main(){
    scanf("%d", &N);
    vi a(N);
    rep(i, N)scanf("%d", &a[i]);

    auto ans = bubbleSort(a);
    printf("%d\n", sz(ans));
    each(x, ans){
        printf("%d %d\n", x.first, x.second);
    }
    fflush(stdout);
    int dummy;
    scanf("%d", &dummy);
}
0