結果

問題 No.397 NO MORE KADOMATSU
ユーザー furafura
提出日時 2020-04-28 20:20:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 447 bytes
コンパイル時間 1,998 ms
コンパイル使用メモリ 202,480 KB
実行使用メモリ 24,384 KB
平均クエリ数 36.83
最終ジャッジ日時 2023-09-24 02:36:17
合計ジャッジ時間 3,528 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
24,384 KB
testcase_01 AC 24 ms
23,364 KB
testcase_02 AC 24 ms
24,168 KB
testcase_03 AC 24 ms
23,352 KB
testcase_04 AC 24 ms
23,496 KB
testcase_05 AC 23 ms
23,928 KB
testcase_06 AC 25 ms
24,036 KB
testcase_07 AC 23 ms
23,760 KB
testcase_08 AC 23 ms
23,628 KB
testcase_09 AC 24 ms
24,060 KB
testcase_10 AC 24 ms
24,372 KB
testcase_11 AC 23 ms
23,688 KB
testcase_12 AC 24 ms
23,556 KB
testcase_13 AC 26 ms
24,060 KB
testcase_14 AC 23 ms
23,988 KB
testcase_15 AC 23 ms
23,556 KB
testcase_16 AC 23 ms
24,168 KB
testcase_17 AC 23 ms
23,568 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);

	return 0;
}
0