結果

問題 No.397 NO MORE KADOMATSU
ユーザー algon_320algon_320
提出日時 2016-07-15 22:58:14
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 810 bytes
コンパイル時間 1,205 ms
コンパイル使用メモリ 148,336 KB
実行使用メモリ 24,540 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-23 11:03:58
合計ジャッジ時間 5,270 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 25 ms
24,396 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 27 ms
24,276 KB
testcase_10 WA -
testcase_11 AC 25 ms
23,880 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 25 ms
23,268 KB
testcase_17 AC 25 ms
23,412 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,i+1));
                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