結果

問題 No.397 NO MORE KADOMATSU
ユーザー tossytossy
提出日時 2016-07-15 22:45:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 935 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 24,336 KB
平均クエリ数 819.72
最終ジャッジ日時 2023-09-24 00:13:43
合計ジャッジ時間 2,541 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
24,120 KB
testcase_01 AC 24 ms
23,436 KB
testcase_02 AC 25 ms
23,400 KB
testcase_03 AC 32 ms
24,276 KB
testcase_04 AC 26 ms
23,808 KB
testcase_05 AC 30 ms
23,652 KB
testcase_06 AC 27 ms
23,400 KB
testcase_07 AC 27 ms
23,640 KB
testcase_08 AC 25 ms
24,288 KB
testcase_09 AC 24 ms
23,592 KB
testcase_10 AC 23 ms
23,400 KB
testcase_11 AC 24 ms
24,120 KB
testcase_12 AC 31 ms
23,652 KB
testcase_13 AC 33 ms
23,580 KB
testcase_14 AC 33 ms
24,048 KB
testcase_15 AC 33 ms
24,336 KB
testcase_16 AC 25 ms
24,288 KB
testcase_17 AC 23 ms
23,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define INF 1<<30
typedef pair<int, int> P;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){scanf("%d", &a[i]);}

    vector<P> vec;
    rep(i,n){
        for(int j=0; j<n-1-i; j++){
            if(a[j]<a[j+1]){
                vec.pb(mp(j,j+1));
                swap(a[j], a[j+1]);
            }
        }
    }

    cout<<vec.size()<<endl;
    rep(i,vec.size()) printf("%d %d\n", vec[i].first, vec[i].second);

    cin>>n;

    return 0;
}
0