結果

問題 No.397 NO MORE KADOMATSU
ユーザー kapokapo
提出日時 2016-07-17 11:18:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,162 bytes
コンパイル時間 711 ms
コンパイル使用メモリ 72,420 KB
実行使用メモリ 24,516 KB
平均クエリ数 181.78
最終ジャッジ日時 2023-09-23 11:11:31
合計ジャッジ時間 3,636 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,264 KB
testcase_01 AC 26 ms
23,412 KB
testcase_02 AC 25 ms
23,412 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 24 ms
23,388 KB
testcase_10 WA -
testcase_11 AC 26 ms
24,384 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 26 ms
23,640 KB
testcase_17 AC 26 ms
23,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <sstream>
#include <cmath>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()

typedef pair<int, int> Pii;
typedef vector<int> V;
typedef long long ll;
const int inf = 1e9;
const int mod = 1e9 + 7;

int N;
int A[100] = {};
int cnt = 0;
V ans[2];

void quick_sort(int l, int r)
{
    if(l>=r) return;
    int p = l;
    int k = l+1;
    while(k<=r) {
        if(A[p]>A[k]) {
            ans[0].pb(p);
            ans[1].pb(k);
            cnt++;

            swap(A[p+1],A[k]);
            p++;
        }
        k++;
    }
	swap(A[l],A[p]);
    quick_sort(l,p-1);
    quick_sort(p+1,r);
    return;
}

int main()
{
    cin >> N;
    rep(i,0,N) cin >> A[i];

    quick_sort(0,N-1);
    //rep(i,0,N) cout << A[i] << " "; cout << endl;

    cout << cnt << endl;
    rep(i,0,cnt) {
        cout << ans[0][i] << " " << ans[1][i] << endl;
    }
    cout << flush;
    cin >> N;

    return 0;
}
0