結果

問題 No.397 NO MORE KADOMATSU
ユーザー kotamanegikotamanegi
提出日時 2016-07-15 22:44:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,118 bytes
コンパイル時間 1,043 ms
コンパイル使用メモリ 92,728 KB
実行使用メモリ 24,348 KB
平均クエリ数 36.83
最終ジャッジ日時 2023-09-24 00:13:38
合計ジャッジ時間 2,402 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,364 KB
testcase_01 AC 23 ms
23,364 KB
testcase_02 AC 23 ms
24,036 KB
testcase_03 AC 23 ms
24,036 KB
testcase_04 AC 23 ms
24,348 KB
testcase_05 AC 24 ms
23,796 KB
testcase_06 AC 22 ms
24,300 KB
testcase_07 AC 24 ms
23,508 KB
testcase_08 AC 23 ms
24,036 KB
testcase_09 AC 23 ms
24,048 KB
testcase_10 AC 23 ms
23,508 KB
testcase_11 AC 24 ms
23,628 KB
testcase_12 AC 23 ms
23,520 KB
testcase_13 AC 24 ms
23,640 KB
testcase_14 AC 24 ms
24,240 KB
testcase_15 AC 24 ms
23,628 KB
testcase_16 AC 23 ms
23,352 KB
testcase_17 AC 22 ms
24,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <iomanip>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
int hoge_now[1000] = {};
int main() {
	int n;
	cin >> n;
	vector<int> a;
	REP(i, n) {
		int hoge;
		cin >> hoge;
		a.push_back(hoge);
		hoge_now[i] = hoge;
	}
	sort(a.begin(), a.end());
	int ans = 0;
	vector<pair<int, int>> rep;
	for (int i = 0;i < n;++i) {
		for (int q = i;q < n;++q) {
			if (a[i] == hoge_now[q]) {
				if (i != q) {
					ans++;
					rep.push_back(make_pair(i, q));
					swap(hoge_now[i], hoge_now[q]);
				}
				goto next;
			}
		}
	next:;
	}
	cout << ans << endl;
	for (int i = 0;i < ans;++i) {
		cout << rep[i].first << " " << rep[i].second << endl;
	}
	int dummy;
	cin >> dummy;
	return 0;
}
0