結果
| 問題 |
No.2421 entersys?
|
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2023-08-12 14:26:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,280 bytes |
| コンパイル時間 | 2,996 ms |
| コンパイル使用メモリ | 232,904 KB |
| 最終ジャッジ日時 | 2025-02-16 04:50:04 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 12 WA * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "settings/debug.cpp"
#define _GLIBCXX_DEBUG
#else
#define Debug(...) void(0)
#endif
using 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 };
}
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 };
}
}
int comp_cnt = 0;
{ // compress
set<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];
entered[x].insert(l);
exited[x].insert(r);
entered[x].insert(2e9);
exited[x].insert(2e9);
fw.add(l, 1);
fw.add(r + 1, -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];
entered[x].insert(l);
exited[x].insert(r);
fw.add(l, 1);
fw.add(r + 1, -1);
}
}
return 0;
}
a01sa01to