結果

問題 No.397 NO MORE KADOMATSU
ユーザー ShibuyapShibuyap
提出日時 2020-09-09 14:41:55
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 769 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 202,292 KB
実行使用メモリ 24,384 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 02:45:46
合計ジャッジ時間 3,907 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
24,072 KB
testcase_01 AC 25 ms
23,616 KB
testcase_02 AC 25 ms
24,060 KB
testcase_03 AC 27 ms
24,072 KB
testcase_04 AC 25 ms
23,688 KB
testcase_05 AC 28 ms
23,700 KB
testcase_06 AC 28 ms
23,604 KB
testcase_07 AC 29 ms
23,712 KB
testcase_08 AC 26 ms
24,324 KB
testcase_09 AC 25 ms
24,096 KB
testcase_10 AC 52 ms
24,384 KB
testcase_11 AC 25 ms
24,120 KB
testcase_12 AC 33 ms
23,616 KB
testcase_13 AC 38 ms
23,904 KB
testcase_14 AC 36 ms
24,084 KB
testcase_15 AC 36 ms
23,616 KB
testcase_16 AC 25 ms
24,108 KB
testcase_17 AC 26 ms
24,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;

    int a[n] = {};
    rep(i,n) cin >> a[i];

    vector<P> v;
    rep(i,1000){
        rep(j,n-1){
            if(a[j]>a[j+1]){
                v.push_back(P(j,j+1));
                swap(a[j],a[j+1]);
            }
        }
    }    
    int ans = v.size();
    cout << ans << endl;
    rep(i,ans) cout << v[i].first << ' ' << v[i].second << endl;
    fflush(stdout);
    int dummy;
    cin >> dummy;
    return 0;
}
 
 
0