結果

問題 No.397 NO MORE KADOMATSU
ユーザー furafura
提出日時 2020-04-28 20:19:38
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 2,323 ms
コンパイル使用メモリ 201,632 KB
実行使用メモリ 24,348 KB
平均クエリ数 36.83
最終ジャッジ日時 2023-09-24 02:36:09
合計ジャッジ時間 3,775 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,496 KB
testcase_01 AC 23 ms
23,652 KB
testcase_02 AC 23 ms
23,856 KB
testcase_03 AC 24 ms
24,348 KB
testcase_04 AC 22 ms
23,784 KB
testcase_05 AC 23 ms
24,216 KB
testcase_06 AC 23 ms
23,664 KB
testcase_07 AC 23 ms
23,628 KB
testcase_08 AC 22 ms
24,336 KB
testcase_09 AC 25 ms
23,400 KB
testcase_10 AC 24 ms
24,156 KB
testcase_11 AC 23 ms
24,348 KB
testcase_12 AC 22 ms
23,988 KB
testcase_13 AC 23 ms
23,640 KB
testcase_14 AC 25 ms
23,328 KB
testcase_15 AC 23 ms
23,256 KB
testcase_16 AC 23 ms
24,060 KB
testcase_17 AC 22 ms
23,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

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

	printf("%lu\n",ans.size());
	for(auto p:ans) printf("%d %d\n",p.first,p.second);
	fflush(stdout);
	scanf("%*d");

	return 0;
}
0