結果

問題 No.2740 Old Maid
ユーザー true-moleculetrue-molecule
提出日時 2024-04-20 22:19:15
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 480 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 1,258 ms
コンパイル使用メモリ 105,320 KB
実行使用メモリ 23,432 KB
最終ジャッジ日時 2024-04-20 22:19:30
合計ジャッジ時間 13,870 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 271 ms
23,432 KB
testcase_01 AC 283 ms
23,304 KB
testcase_02 AC 286 ms
23,304 KB
testcase_03 AC 286 ms
23,176 KB
testcase_04 AC 280 ms
23,300 KB
testcase_05 AC 282 ms
23,180 KB
testcase_06 AC 290 ms
23,176 KB
testcase_07 AC 287 ms
23,176 KB
testcase_08 AC 287 ms
23,180 KB
testcase_09 AC 283 ms
23,176 KB
testcase_10 AC 302 ms
23,176 KB
testcase_11 AC 264 ms
23,304 KB
testcase_12 AC 272 ms
17,428 KB
testcase_13 AC 325 ms
18,492 KB
testcase_14 AC 49 ms
6,940 KB
testcase_15 AC 73 ms
7,760 KB
testcase_16 AC 188 ms
13,952 KB
testcase_17 AC 44 ms
6,944 KB
testcase_18 AC 299 ms
17,924 KB
testcase_19 AC 96 ms
9,392 KB
testcase_20 AC 355 ms
20,176 KB
testcase_21 AC 55 ms
7,096 KB
testcase_22 AC 182 ms
13,824 KB
testcase_23 AC 33 ms
6,944 KB
testcase_24 AC 96 ms
9,336 KB
testcase_25 AC 441 ms
21,184 KB
testcase_26 AC 4 ms
6,940 KB
testcase_27 AC 21 ms
6,944 KB
testcase_28 AC 200 ms
13,824 KB
testcase_29 AC 196 ms
13,568 KB
testcase_30 AC 8 ms
6,940 KB
testcase_31 AC 480 ms
22,792 KB
testcase_32 AC 114 ms
10,240 KB
testcase_33 AC 457 ms
21,744 KB
testcase_34 AC 199 ms
13,184 KB
testcase_35 AC 89 ms
9,128 KB
testcase_36 AC 97 ms
9,472 KB
testcase_37 AC 143 ms
11,648 KB
testcase_38 AC 78 ms
8,432 KB
testcase_39 AC 40 ms
6,940 KB
testcase_40 AC 240 ms
15,872 KB
testcase_41 AC 357 ms
19,980 KB
testcase_42 AC 2 ms
6,940 KB
testcase_43 AC 2 ms
6,940 KB
testcase_44 AC 2 ms
6,944 KB
testcase_45 AC 2 ms
6,940 KB
testcase_46 AC 2 ms
6,940 KB
testcase_47 AC 2 ms
6,940 KB
testcase_48 AC 2 ms
6,940 KB
testcase_49 AC 2 ms
6,944 KB
testcase_50 AC 2 ms
6,940 KB
testcase_51 AC 2 ms
6,940 KB
testcase_52 AC 2 ms
6,940 KB
testcase_53 AC 1 ms
6,940 KB
testcase_54 AC 2 ms
6,944 KB
testcase_55 AC 2 ms
6,940 KB
testcase_56 AC 2 ms
6,940 KB
testcase_57 AC 2 ms
6,944 KB
testcase_58 AC 2 ms
6,944 KB
testcase_59 AC 2 ms
6,940 KB
testcase_60 AC 1 ms
6,944 KB
testcase_61 AC 2 ms
6,940 KB
testcase_62 AC 2 ms
6,944 KB
testcase_63 AC 2 ms
6,944 KB
testcase_64 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
}
0