結果

問題 No.397 NO MORE KADOMATSU
ユーザー tabataba
提出日時 2017-05-19 03:36:40
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 677 bytes
コンパイル時間 1,878 ms
コンパイル使用メモリ 107,676 KB
実行使用メモリ 36,388 KB
最終ジャッジ日時 2023-09-24 01:16:26
合計ジャッジ時間 7,567 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
権限があれば一括ダウンロードができます

ソースコード

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());
	for(auto i:u){
		printf("%ld %ld\n",i[0],i[1]);
	}
	-scanf("%ld",&n);
	return 0;
}
0