結果
問題 | No.397 NO MORE KADOMATSU |
ユーザー |
![]() |
提出日時 | 2016-07-15 22:44:20 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 1,118 bytes |
コンパイル時間 | 1,011 ms |
コンパイル使用メモリ | 92,732 KB |
実行使用メモリ | 25,220 KB |
平均クエリ数 | 36.83 |
最終ジャッジ日時 | 2024-07-17 00:04:00 |
合計ジャッジ時間 | 2,605 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
#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; }