結果
| 問題 |
No.2421 entersys?
|
| コンテスト | |
| ユーザー |
kwm_t
|
| 提出日時 | 2023-08-12 16:45:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 573 ms / 3,000 ms |
| コード長 | 2,861 bytes |
| コンパイル時間 | 5,614 ms |
| コンパイル使用メモリ | 279,420 KB |
| 最終ジャッジ日時 | 2025-02-16 07:17:14 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
template <class S>
struct value_compression : vector<S> {
bool built = false;
using VS = vector<S>;
using VS::VS;
value_compression(vector<S> v = {}) : vector<S>(move(v)) {}
void build() {
sort(this->begin(), this->end());
this->erase(unique(this->begin(), this->end()), this->end());
built = true;
}
template <class T>
void convert(T first, T last) {
assert(built);
for (; first != last; ++first) *first = (*this)(*first);
}
int operator()(S x) {
assert(built);
return lower_bound(this->begin(), this->end(), x) - this->begin();
}
void clear() {
this->clear();
built = false;
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
vector<tuple<string, int, int>> inp(n);
value_compression<string> name;
value_compression<int> time;
for (auto&[x, l, r] : inp) {
cin >> x >> l >> r, l--;
name.emplace_back(x);
time.emplace_back(l);
time.emplace_back(r);
}
int q; cin >> q;
struct Q {
int type;
string x;
int l, r;
};
vector<Q>query(q);
for (auto &[type, x, l, r] : query) {
cin >> type;
if (1 == type) {
cin >> x >> l;
l--;
name.push_back(x);
time.push_back(l);
}
else if (2 == type) {
cin >> l;
l--;
time.push_back(l);
}
else {
cin >> x >> l >> r;
l--;
name.push_back(x);
time.push_back(l);
time.push_back(r);
}
}
name.build();
time.build();
vector<map<int, int>> memo(name.size());
fenwick_tree<int> ft(time.size());
for (auto&[x, l, r] : inp) {
int p = name(x);
l = time(l);
r = time(r);
memo[p][r] = l;
ft.add(l, 1);
ft.add(r, -1);
}
for (auto &[type, x, l, r] : query) {
if (1 == type) {
int p = name(x);
l = time(l);
auto it = memo[p].upper_bound(l);
bool ok = it != memo[p].end() && it->second <= l;
cout << (ok ? "Yes\n" : "No\n");
}
else if (2 == type) {
l = time(l);
cout << ft.sum(0, l + 1) << endl;
}
else {
int p = name(x);
l = time(l);
r = time(r);
memo[p][r] = l;
ft.add(l, 1);
ft.add(r, -1);
}
}
return 0;
}
kwm_t