結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,676 KB
testcase_01 AC 25 ms
23,400 KB
testcase_02 AC 25 ms
24,024 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 25 ms
24,060 KB
testcase_10 AC 54 ms
24,372 KB
testcase_11 AC 25 ms
23,388 KB
testcase_12 AC 26 ms
24,048 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 26 ms
23,544 KB
testcase_17 AC 25 ms
23,376 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 vector<V> VV;
typedef vector<VV> VVV;
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],A[k]);
			p++;
		}
		k++;
	}
	quick_sort(l,p);
	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