結果

問題 No.397 NO MORE KADOMATSU
ユーザー hanorverhanorver
提出日時 2016-07-15 23:06:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 72,284 KB
実行使用メモリ 24,384 KB
平均クエリ数 651.67
最終ジャッジ日時 2023-09-24 00:16:29
合計ジャッジ時間 2,340 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,376 KB
testcase_01 AC 24 ms
23,820 KB
testcase_02 AC 24 ms
24,384 KB
testcase_03 AC 25 ms
24,168 KB
testcase_04 AC 25 ms
23,412 KB
testcase_05 AC 25 ms
23,820 KB
testcase_06 AC 25 ms
23,664 KB
testcase_07 AC 25 ms
23,976 KB
testcase_08 AC 25 ms
23,388 KB
testcase_09 AC 24 ms
24,024 KB
testcase_10 AC 53 ms
23,508 KB
testcase_11 AC 24 ms
24,252 KB
testcase_12 AC 24 ms
23,520 KB
testcase_13 AC 34 ms
23,640 KB
testcase_14 AC 34 ms
23,652 KB
testcase_15 AC 35 ms
24,276 KB
testcase_16 AC 24 ms
23,640 KB
testcase_17 AC 25 ms
23,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

int main() {
	int m;

	std::cin >> m;

	std::vector<int> v(m);
	for (int i = 0; i < m; i++) {
		std::cin >> v[i];
	}

	std::vector<std::pair<int, int> > ans;

	for (int i = 0; i < m; i++) {
		for (int j = i + 1; j < m; j++) {
			if (v[i] > v[j]) {
				ans.push_back({ i, j });
				std::swap(v[i], v[j]);
			}
		}
	}

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

	int dm;

	std::cin >> dm;

	return 0;
}
0