結果
問題 | No.2421 entersys? |
ユーザー |
![]() |
提出日時 | 2023-08-12 14:37:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,184 ms / 3,000 ms |
コード長 | 2,687 bytes |
コンパイル時間 | 2,517 ms |
コンパイル使用メモリ | 235,736 KB |
最終ジャッジ日時 | 2025-02-16 05:07:43 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h>using namespace std;#ifdef LOCAL#include "settings/debug.cpp"#define _GLIBCXX_DEBUG#else#define Debug(...) void(0)#endifusing ll = long long;#define rep(i, n) for (int i = 0; i < (n); ++i)#include <atcoder/fenwicktree>int main() {int n;cin >> n;vector<tuple<string, int, int>> info(n);rep(i, n) {string x;int l, r;cin >> x >> l >> r;info[i] = { x, l, r + 1 };}int q;cin >> q;vector<tuple<int, string, int, int>> query(q);rep(i, q) {int qtype;cin >> qtype;if (qtype == 1) {string x;int t;cin >> x >> t;query[i] = { qtype, x, t, -1 };}if (qtype == 2) {int t;cin >> t;query[i] = { qtype, "", t, -1 };}if (qtype == 3) {string x;int l, r;cin >> x >> l >> r;query[i] = { qtype, x, l, r + 1 };}}int comp_cnt = 0;{ // compressset<int> st;rep(i, n) {auto [_, l, r] = info[i];st.insert(l), st.insert(r);}rep(i, q) {auto [_, __, l, r] = query[i];st.insert(l), st.insert(r);}st.erase(-1);map<int, int> mp;for (int x : st) mp[x] = comp_cnt++;mp[-1] = -1;rep(i, n) {auto&& [_, l, r] = info[i];l = mp[l], r = mp[r];}rep(i, q) {auto&& [_, __, l, r] = query[i];l = mp[l], r = mp[r];}}map<string, set<int>> entered, exited;atcoder::fenwick_tree<int> fw(comp_cnt + 1);rep(i, n) {auto [x, l, r] = info[i];if (exited[x].count(l)) {exited[x].erase(l);}else {entered[x].insert(l);}if (entered[x].count(r)) {entered[x].erase(r);}else {exited[x].insert(r);}entered[x].insert(2e9);exited[x].insert(2e9);fw.add(l, 1);fw.add(r, -1);}rep(i, q) {int qtype = get<0>(query[i]);if (qtype == 1) {auto [_, x, t, __] = query[i];int l = *entered[x].upper_bound(t);int r = *exited[x].upper_bound(t);if (r < l) {cout << "Yes" << endl;}else {cout << "No" << endl;}}if (qtype == 2) {auto [_, __, t, ___] = query[i];cout << fw.sum(0, t + 1) << endl;}if (qtype == 3) {auto [_, x, l, r] = query[i];if (exited[x].count(l)) {exited[x].erase(l);}else {entered[x].insert(l);}if (entered[x].count(r)) {entered[x].erase(r);}else {exited[x].insert(r);}entered[x].insert(2e9);exited[x].insert(2e9);fw.add(l, 1);fw.add(r, -1);}}return 0;}