結果

問題 No.397 NO MORE KADOMATSU
ユーザー tabataba
提出日時 2017-05-19 03:39:17
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 712 bytes
コンパイル時間 1,310 ms
コンパイル使用メモリ 137,620 KB
実行使用メモリ 24,396 KB
平均クエリ数 36.83
最終ジャッジ日時 2023-09-24 01:16:29
合計ジャッジ時間 2,984 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,292 KB
testcase_01 AC 22 ms
23,580 KB
testcase_02 AC 22 ms
23,340 KB
testcase_03 AC 23 ms
24,396 KB
testcase_04 AC 23 ms
23,628 KB
testcase_05 AC 23 ms
24,276 KB
testcase_06 AC 24 ms
24,240 KB
testcase_07 AC 24 ms
23,976 KB
testcase_08 AC 22 ms
23,292 KB
testcase_09 AC 23 ms
23,472 KB
testcase_10 AC 23 ms
23,952 KB
testcase_11 AC 22 ms
23,820 KB
testcase_12 AC 25 ms
23,604 KB
testcase_13 AC 23 ms
23,376 KB
testcase_14 AC 23 ms
23,604 KB
testcase_15 AC 23 ms
23,388 KB
testcase_16 AC 22 ms
24,048 KB
testcase_17 AC 23 ms
23,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <random>
#include <vector>
#include <algorithm>
#include <array>
#include <functional>
#include <utility>
#include <regex>
#include <tuple>
#include <map>

using namespace std;

int main(){
	int64_t n;
	-scanf("%ld",&n);
	vector<int> a(n);
	for(int i=0;i<n;i++){
		-scanf("%d",&a[i]);
	}
	vector<array<int64_t,2>> u;
	for(auto it=a.begin();it<a.end();it++){
		auto maxe=min_element(it,a.end());
		if(it!=maxe){
			u.push_back({it-a.begin(),maxe-a.begin()});
			swap(*it,*maxe);
		}
	}
	printf("%ld\n",u.size());
	fflush(stdout);
	for(auto i:u){
		printf("%ld %ld\n",i[0],i[1]);
		fflush(stdout);
	}
	-scanf("%ld",&n);
	return 0;
}
0