結果

問題 No.945 YKC饅頭
ユーザー Akidai16Akidai16
提出日時 2022-12-06 00:52:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 363 ms / 2,000 ms
コード長 1,838 bytes
コンパイル時間 4,370 ms
コンパイル使用メモリ 262,672 KB
実行使用メモリ 44,500 KB
最終ジャッジ日時 2024-04-20 22:23:02
合計ジャッジ時間 11,892 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 3 ms
6,944 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 3 ms
6,944 KB
testcase_25 AC 3 ms
6,940 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,948 KB
testcase_30 AC 1 ms
6,944 KB
testcase_31 AC 14 ms
6,940 KB
testcase_32 AC 8 ms
6,948 KB
testcase_33 AC 53 ms
14,076 KB
testcase_34 AC 133 ms
24,860 KB
testcase_35 AC 268 ms
39,320 KB
testcase_36 AC 172 ms
33,880 KB
testcase_37 AC 157 ms
31,860 KB
testcase_38 AC 142 ms
26,004 KB
testcase_39 AC 36 ms
9,600 KB
testcase_40 AC 30 ms
10,496 KB
testcase_41 AC 13 ms
7,040 KB
testcase_42 AC 201 ms
35,620 KB
testcase_43 AC 143 ms
32,096 KB
testcase_44 AC 171 ms
29,504 KB
testcase_45 AC 218 ms
39,268 KB
testcase_46 AC 6 ms
6,940 KB
testcase_47 AC 127 ms
24,432 KB
testcase_48 AC 31 ms
8,312 KB
testcase_49 AC 62 ms
13,588 KB
testcase_50 AC 239 ms
40,460 KB
testcase_51 AC 331 ms
44,336 KB
testcase_52 AC 363 ms
44,500 KB
testcase_53 AC 294 ms
44,256 KB
testcase_54 AC 282 ms
44,256 KB
testcase_55 AC 348 ms
44,128 KB
testcase_56 AC 10 ms
8,624 KB
testcase_57 AC 7 ms
8,720 KB
testcase_58 AC 163 ms
24,592 KB
testcase_59 AC 204 ms
28,116 KB
testcase_60 AC 67 ms
15,324 KB
testcase_61 AC 176 ms
25,636 KB
testcase_62 AC 168 ms
24,852 KB
testcase_63 AC 7 ms
8,980 KB
testcase_64 AC 76 ms
15,952 KB
testcase_65 AC 59 ms
14,296 KB
testcase_66 AC 54 ms
14,084 KB
testcase_67 AC 120 ms
20,532 KB
testcase_68 AC 67 ms
15,492 KB
testcase_69 AC 25 ms
11,024 KB
testcase_70 AC 31 ms
11,484 KB
testcase_71 AC 30 ms
11,596 KB
testcase_72 AC 91 ms
17,924 KB
testcase_73 AC 196 ms
26,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)
#define All(A) A.begin(), A.end()
#define rAll(A) A.rbegin(), A.rend()

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int N, M;
vvi Q;

void solve() {
    vi ans(N, -1);
    reverse(All(Q));
    vector<vvi> A(N);
    REP(i, 0, M) {
        int l = Q[i][0], r = Q[i][1], c = Q[i][2];
        A[l].push_back({i, r, c});
    }
    priority_queue<vi> P;
    REP(i, 0, N) {
        for(vi a: A[i]) {
            P.push(a);
            // cout << "pushed: " << a[0] << " " << a[1] << " " << a[2] << endl;
        }
        if(P.empty()) continue;
        vi top = P.top();
        int priority = top[0], r = top[1], c = top[2];
        // cout << priority << " " << r << " " << c << endl;
        while(r < i) {
            P.pop();
            if(P.empty()) {
                c = -1;
                break;
            }
            top = P.top();
            priority = top[0], r = top[1], c = top[2];
        }
        ans[i] = c;
        /*
        REP(i, 0, N) cout << ans[i] << " ";
        cout << endl;
        */
    }
    vi cnt(3, 0);
    REP(i, 0, N) {
        if(ans[i] == -1) continue;
        cnt[ans[i]]++;
    }
    REP(i, 0, 3) {
        cout << cnt[i] << " ";
    }
    cout << endl;
}

int main() {
    cin >> N >> M;
    Q.resize(M);
    REP(i, 0, M) {
        int l, r;
        char t;
        cin >> l >> r >> t;
        l--; r--;
        int c = 0;
        if(t == 'K') c = 1;
        if(t == 'C') c = 2;
        Q[i] = {l, r, c};
    }
    solve();
}
0