結果
| 問題 |
No.2740 Old Maid
|
| コンテスト | |
| ユーザー |
true-molecule
|
| 提出日時 | 2024-04-20 22:19:15 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 463 ms / 2,000 ms |
| コード長 | 754 bytes |
| コンパイル時間 | 1,177 ms |
| コンパイル使用メモリ | 107,808 KB |
| 実行使用メモリ | 23,224 KB |
| 最終ジャッジ日時 | 2024-10-12 20:38:07 |
| 合計ジャッジ時間 | 13,604 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 62 |
ソースコード
#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) {
auto it = s.lower_bound({m.at(j) + 1, 0});
if (it == s.end())
continue;
ans.push_back(j);
s.erase({m.at(j), j});
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';
}
true-molecule