結果

問題 No.397 NO MORE KADOMATSU
ユーザー pekempeypekempey
提出日時 2016-07-15 22:30:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 1,171 ms
コンパイル使用メモリ 148,924 KB
実行使用メモリ 24,420 KB
平均クエリ数 651.67
最終ジャッジ日時 2023-09-24 00:12:27
合計ジャッジ時間 3,015 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,448 KB
testcase_01 AC 25 ms
23,676 KB
testcase_02 AC 25 ms
23,700 KB
testcase_03 AC 26 ms
24,048 KB
testcase_04 AC 25 ms
23,400 KB
testcase_05 AC 27 ms
23,664 KB
testcase_06 AC 27 ms
24,048 KB
testcase_07 AC 27 ms
23,556 KB
testcase_08 AC 27 ms
24,036 KB
testcase_09 AC 26 ms
24,036 KB
testcase_10 AC 54 ms
23,772 KB
testcase_11 AC 26 ms
23,592 KB
testcase_12 AC 26 ms
24,408 KB
testcase_13 AC 34 ms
23,808 KB
testcase_14 AC 34 ms
23,664 KB
testcase_15 AC 35 ms
23,424 KB
testcase_16 AC 26 ms
24,048 KB
testcase_17 AC 25 ms
24,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin >> n;

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	vector<pair<int, int>> ans;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] > a[j]) {
				ans.emplace_back(i, j);
				swap(a[i], a[j]);
			}
		}
	}

	cout << ans.size() << endl;
	for (auto p : ans) {
		cout << p.first << " " << p.second << endl;
	}

	int dummy;
	cin >> dummy;
}
0