Submission #48588959


Source Code Expand

/**
 *  @the_hyp0cr1t3
 *  16.12.2023 17:49
**/
#include <bits/stdc++.h>

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    int n;
    std::cin >> n;
    std::vector<int> t(n), x(n);
    for (int i = 0; i < n; i++)
        std::cin >> t[i] >> x[i];

    std::vector<int> res(n, -1);
    std::map<int, std::vector<int>> have;
    for (int i = 0; i < n; i++) {
        if (t[i] == 1) {
            have[x[i]].push_back(i);
            res[i] = 0;
        } else {
            if (have[x[i]].empty()) {
                std::cout << -1 << '\n';
                return 0;
            }
            int v = have[x[i]].back();
            have[x[i]].pop_back();
            res[v] = 1;
        }
    }

    auto pref = res;
    for (int i = 1; i < n; i++)
        pref[i] += pref[i - 1];

    std::cout << std::ranges::max(pref) << '\n';
    for (auto z : res)
        if (~z) std::cout << z << ' ';;
    std::cout << '\n';
}

Submission Info

Submission Time
Task E - Takahashi Quest
User the_hyp0cr1t3
Language C++ 20 (gcc 12.2)
Score 450
Code Size 979 Byte
Status AC
Exec Time 130 ms
Memory 28120 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 3
AC × 47
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 02_handmade_39.txt, 02_handmade_40.txt, 02_handmade_41.txt, 02_handmade_42.txt, 02_handmade_43.txt, 02_handmade_44.txt, 02_handmade_45.txt, 02_handmade_46.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3500 KiB
00_sample_01.txt AC 1 ms 3508 KiB
00_sample_02.txt AC 1 ms 3504 KiB
01_random_03.txt AC 3 ms 3668 KiB
01_random_04.txt AC 12 ms 4376 KiB
01_random_05.txt AC 43 ms 6740 KiB
01_random_06.txt AC 40 ms 6128 KiB
01_random_07.txt AC 3 ms 3776 KiB
01_random_08.txt AC 12 ms 4048 KiB
01_random_09.txt AC 9 ms 4440 KiB
01_random_10.txt AC 4 ms 3580 KiB
01_random_11.txt AC 14 ms 4812 KiB
01_random_12.txt AC 5 ms 3640 KiB
01_random_13.txt AC 13 ms 4896 KiB
01_random_14.txt AC 6 ms 3792 KiB
01_random_15.txt AC 39 ms 5924 KiB
01_random_16.txt AC 18 ms 4708 KiB
01_random_17.txt AC 12 ms 5280 KiB
01_random_18.txt AC 20 ms 4632 KiB
01_random_19.txt AC 33 ms 5668 KiB
01_random_20.txt AC 3 ms 3772 KiB
01_random_21.txt AC 50 ms 6720 KiB
01_random_22.txt AC 55 ms 7536 KiB
01_random_23.txt AC 63 ms 8668 KiB
01_random_24.txt AC 16 ms 5580 KiB
01_random_25.txt AC 16 ms 5340 KiB
01_random_26.txt AC 17 ms 5572 KiB
01_random_27.txt AC 58 ms 7452 KiB
01_random_28.txt AC 55 ms 7260 KiB
01_random_29.txt AC 57 ms 7248 KiB
01_random_30.txt AC 21 ms 6208 KiB
01_random_31.txt AC 15 ms 5424 KiB
01_random_32.txt AC 20 ms 6168 KiB
01_random_33.txt AC 119 ms 28120 KiB
01_random_34.txt AC 17 ms 5344 KiB
01_random_35.txt AC 102 ms 17100 KiB
01_random_36.txt AC 41 ms 8068 KiB
01_random_37.txt AC 13 ms 5216 KiB
01_random_38.txt AC 48 ms 6728 KiB
02_handmade_39.txt AC 123 ms 17036 KiB
02_handmade_40.txt AC 130 ms 17016 KiB
02_handmade_41.txt AC 103 ms 17032 KiB
02_handmade_42.txt AC 65 ms 16996 KiB
02_handmade_43.txt AC 64 ms 17040 KiB
02_handmade_44.txt AC 66 ms 17068 KiB
02_handmade_45.txt AC 1 ms 3508 KiB
02_handmade_46.txt AC 1 ms 3436 KiB