結果
問題 |
No.2740 Old Maid
|
ユーザー |
![]() |
提出日時 | 2024-04-20 22:13:32 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 766 bytes |
コンパイル時間 | 1,326 ms |
コンパイル使用メモリ | 107,428 KB |
実行使用メモリ | 23,436 KB |
最終ジャッジ日時 | 2024-10-12 20:32:00 |
合計ジャッジ時間 | 22,522 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 RE * 53 |
ソースコード
#include <iostream> #include <map> #include <set> #include <vector> int main() { using namespace std; int n; cin >> n; map<int, int> m; set<pair<int, int>> s; vector<int> ans; for (int p, i = 0; i < n; ++i) cin >> p, s.emplace(i, p), m[p] = i; for (int j = 1; j <= n; ++j) if (m.at(j) < n - 1) { ans.push_back(j); s.erase({m.at(j), j}); auto it = s.lower_bound({m.at(j) + 1, 0}); auto [_, u] = *it; ans.push_back(u); m.at(u) = n; s.erase(it); } for (bool first = true; const auto& i : ans) { if (first) first = false; else cout << ' '; cout << i; } cout << '\n'; }