結果

問題 No.397 NO MORE KADOMATSU
ユーザー femtofemto
提出日時 2016-07-15 22:46:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 643 bytes
コンパイル時間 509 ms
コンパイル使用メモリ 71,036 KB
実行使用メモリ 24,396 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:14:01
合計ジャッジ時間 2,223 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
24,384 KB
testcase_01 AC 24 ms
23,508 KB
testcase_02 AC 24 ms
23,700 KB
testcase_03 AC 26 ms
24,396 KB
testcase_04 AC 24 ms
24,036 KB
testcase_05 AC 26 ms
23,880 KB
testcase_06 AC 28 ms
24,336 KB
testcase_07 AC 29 ms
23,388 KB
testcase_08 AC 25 ms
23,376 KB
testcase_09 AC 24 ms
23,376 KB
testcase_10 AC 51 ms
23,568 KB
testcase_11 AC 24 ms
23,652 KB
testcase_12 AC 31 ms
23,628 KB
testcase_13 AC 37 ms
24,036 KB
testcase_14 AC 38 ms
23,676 KB
testcase_15 AC 36 ms
24,240 KB
testcase_16 AC 24 ms
23,616 KB
testcase_17 AC 24 ms
24,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	int A[100];
	for(int i = 0; i < N; i++) {
		cin >> A[i];
	}

	vector<P> p;
	for(int i = 0; i < N - 1; i++) {
		for(int j = N - 1; j > i; j--) {
			if(A[j - 1] > A[j]) {
				p.push_back(P(j - 1, j));
				swap(A[j - 1], A[j]);
			}
		}
	}

	cout << p.size() << endl;
	cout.flush();
	for(int i = 0; i < p.size(); i++) {
		cout << p[i].first << " " << p[i].second << endl;
		cout.flush();
	}

	cin >> N;
}
0