結果
問題 |
No.2421 entersys?
|
ユーザー |
|
提出日時 | 2023-08-12 15:53:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,696 bytes |
コンパイル時間 | 2,074 ms |
コンパイル使用メモリ | 217,792 KB |
最終ジャッジ日時 | 2025-02-16 07:02:13 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 28 |
ソースコード
#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); 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.lower_bound({e.uid, -e.qid}); if(it->first == e.uid) cout << "Yes\n"; else cout << "No\n"; } else { cout << bt.sum(0, e.qid + 1) << '\n'; } } }