結果
問題 | No.2421 entersys? |
ユーザー | siro53 |
提出日時 | 2023-08-12 16:13:43 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 580 ms / 3,000 ms |
コード長 | 2,016 bytes |
コンパイル時間 | 3,053 ms |
コンパイル使用メモリ | 234,388 KB |
実行使用メモリ | 18,204 KB |
最終ジャッジ日時 | 2024-04-30 11:04:56 |
合計ジャッジ時間 | 12,994 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 3 ms
6,940 KB |
testcase_02 | AC | 4 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 3 ms
6,940 KB |
testcase_05 | AC | 3 ms
6,940 KB |
testcase_06 | AC | 4 ms
6,940 KB |
testcase_07 | AC | 4 ms
6,944 KB |
testcase_08 | AC | 4 ms
6,948 KB |
testcase_09 | AC | 5 ms
6,944 KB |
testcase_10 | AC | 4 ms
6,940 KB |
testcase_11 | AC | 440 ms
15,128 KB |
testcase_12 | AC | 430 ms
15,612 KB |
testcase_13 | AC | 443 ms
16,008 KB |
testcase_14 | AC | 436 ms
15,380 KB |
testcase_15 | AC | 431 ms
15,084 KB |
testcase_16 | AC | 479 ms
17,700 KB |
testcase_17 | AC | 468 ms
16,904 KB |
testcase_18 | AC | 472 ms
18,088 KB |
testcase_19 | AC | 480 ms
18,204 KB |
testcase_20 | AC | 478 ms
17,924 KB |
testcase_21 | AC | 474 ms
17,000 KB |
testcase_22 | AC | 354 ms
15,888 KB |
testcase_23 | AC | 580 ms
17,656 KB |
testcase_24 | AC | 578 ms
18,060 KB |
testcase_25 | AC | 575 ms
17,284 KB |
testcase_26 | AC | 258 ms
12,988 KB |
testcase_27 | AC | 256 ms
12,920 KB |
testcase_28 | AC | 258 ms
12,548 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/fenwicktree> using namespace std; using ll = long long; struct E { int type, time, uid, qid; }; int main() { int N; cin >> N; map<string, int> ID; auto get_id = [&](string x) -> int { if(ID.count(x)) return ID[x]; int res = ID.size(); ID[x] = res; return res; }; vector<E> es; for(int i = 0; i < N; i++) { string x; int L, R; cin >> x >> L >> R; int uid = get_id(x); es.push_back(E{1, L, uid, -1}); es.push_back(E{2, R+1, uid, -1}); } int Q; cin >> Q; for(int i = 0; i < Q; i++) { int t; cin >> t; if(t == 1) { string x; int time; cin >> x >> time; int uid = get_id(x); es.emplace_back(E{3, time, uid, i}); } else if(t == 2) { int time; cin >> time; es.emplace_back(E{4, time, -1, i}); } else { string x; int L, R; cin >> x >> L >> R; int uid = get_id(x); es.emplace_back(E{1, L, uid, i}); es.emplace_back(E{2, R+1, uid, i}); } } sort(es.begin(), es.end(), [](const E& l, const E& r) { if(l.time != r.time) return (l.time < r.time); return (l.type < r.type); }); multiset<pair<int, int>> id_set; atcoder::fenwick_tree<int> bt(Q+1); vector<tuple<int, int, int>> ans; for(const auto& e : es) { if(e.type == 1) { id_set.insert({e.uid, -e.qid}); bt.add(e.qid + 1, 1); } else if(e.type == 2) { id_set.erase(id_set.find({e.uid, -e.qid})); bt.add(e.qid + 1, -1); } else if(e.type == 3) { auto it = id_set.upper_bound({e.uid, -e.qid}); if(e.qid != -1) { if(it != id_set.end() and it->first == e.uid) ans.emplace_back(e.qid, 1, 1); else ans.emplace_back(e.qid, 1, 0); } } else { if(e.qid != -1) ans.emplace_back(e.qid, 2, bt.sum(0, e.qid + 1)); } } sort(ans.begin(), ans.end()); for(const auto& [_, t, v] : ans) { if(t == 1) cout << (v ? "Yes" : "No") << '\n'; else cout << v << '\n'; } }