結果
問題 | No.2421 entersys? |
ユーザー | siro53 |
提出日時 | 2023-08-12 16:09:41 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,998 bytes |
コンパイル時間 | 3,191 ms |
コンパイル使用メモリ | 236,928 KB |
実行使用メモリ | 18,116 KB |
最終ジャッジ日時 | 2024-04-30 11:01:35 |
合計ジャッジ時間 | 12,755 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 3 ms
6,944 KB |
testcase_02 | AC | 4 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 3 ms
6,940 KB |
testcase_05 | AC | 4 ms
6,940 KB |
testcase_06 | AC | 4 ms
6,944 KB |
testcase_07 | AC | 4 ms
6,944 KB |
testcase_08 | AC | 4 ms
6,944 KB |
testcase_09 | AC | 6 ms
6,940 KB |
testcase_10 | AC | 4 ms
6,940 KB |
testcase_11 | AC | 444 ms
15,996 KB |
testcase_12 | AC | 428 ms
15,296 KB |
testcase_13 | AC | 435 ms
15,616 KB |
testcase_14 | AC | 434 ms
15,576 KB |
testcase_15 | AC | 426 ms
15,236 KB |
testcase_16 | AC | 477 ms
17,172 KB |
testcase_17 | AC | 481 ms
17,500 KB |
testcase_18 | AC | 475 ms
17,380 KB |
testcase_19 | AC | 471 ms
16,936 KB |
testcase_20 | AC | 483 ms
16,892 KB |
testcase_21 | AC | 482 ms
17,768 KB |
testcase_22 | AC | 351 ms
16,972 KB |
testcase_23 | AC | 591 ms
18,116 KB |
testcase_24 | AC | 593 ms
17,256 KB |
testcase_25 | AC | 580 ms
17,156 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
ソースコード
#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); }); set<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({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'; } }