結果

問題 No.397 NO MORE KADOMATSU
ユーザー kk
提出日時 2020-07-22 22:33:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 711 bytes
コンパイル時間 2,049 ms
コンパイル使用メモリ 203,444 KB
実行使用メモリ 24,516 KB
平均クエリ数 36.83
最終ジャッジ日時 2023-09-24 02:43:04
合計ジャッジ時間 3,886 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,652 KB
testcase_01 AC 23 ms
24,024 KB
testcase_02 AC 23 ms
24,048 KB
testcase_03 AC 24 ms
24,048 KB
testcase_04 AC 23 ms
24,024 KB
testcase_05 AC 22 ms
24,516 KB
testcase_06 AC 23 ms
23,880 KB
testcase_07 AC 25 ms
24,048 KB
testcase_08 AC 22 ms
23,436 KB
testcase_09 AC 22 ms
24,432 KB
testcase_10 AC 23 ms
24,336 KB
testcase_11 AC 22 ms
24,300 KB
testcase_12 AC 23 ms
24,060 KB
testcase_13 AC 23 ms
24,048 KB
testcase_14 AC 23 ms
23,568 KB
testcase_15 AC 22 ms
24,348 KB
testcase_16 AC 22 ms
24,060 KB
testcase_17 AC 23 ms
24,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const double PI = acos(-1);

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  cin >> n;
  vector<int> a(n);
  REP (i, n) cin >> a[i];

  vector<pair<int, int> > ret;
  REP (i, n) {
    int j = min_element(a.begin() + i, a.end()) - a.begin();
    if (j != i) {
      swap(a[i], a[j]);
      ret.emplace_back(i, j);
    }
  }

  cout << ret.size() << endl;
  REP (i, ret.size())
    cout << ret[i].first << " " << ret[i].second << endl;

  cout.flush();
  int dummy;
  cin >> dummy;
  
  return 0;
}
0