結果
問題 | No.397 NO MORE KADOMATSU |
ユーザー |
![]() |
提出日時 | 2025-03-20 00:31:20 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 732 bytes |
コンパイル時間 | 3,116 ms |
コンパイル使用メモリ | 280,216 KB |
実行使用メモリ | 25,984 KB |
平均クエリ数 | 36.83 |
最終ジャッジ日時 | 2025-03-20 00:31:26 |
合計ジャッジ時間 | 4,950 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<pair<int, int>> ans; rep(i, n) { int minim = i; for (int j = i; j < n; ++j) { if (a[j] < a[minim]) minim = j; } if (i != minim) { swap(a[i], a[minim]); ans.push_back({ i, minim }); } } assert(is_sorted(a.begin(), a.end())); cout << ans.size() << endl; for (auto [x, y] : ans) { cout << x << ' ' << y << endl; } int dummy; cin >> dummy; return 0; }