結果
問題 | No.2421 entersys? |
ユーザー |
![]() |
提出日時 | 2023-08-12 15:18:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,022 ms / 3,000 ms |
コード長 | 3,207 bytes |
コンパイル時間 | 4,619 ms |
コンパイル使用メモリ | 280,948 KB |
最終ジャッジ日時 | 2025-02-16 06:05:03 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h>using namespace std;#include <atcoder/all>using namespace atcoder;template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)#define rep2(i, m ,n) for (int i = (m); i < (long long)(n); i++)#define REP(i, n) for (long long i = 1; i < (long long)(n); i++)typedef long long ll;#define updiv(N,X) (N + X - 1) / X#define all(n) n.begin(),n.end()#define YesNo(Q) Q==1?cout<<"Yes":cout<<"No"using P = pair<int, int>;using mint = modint;const int MOD = 998244353LL;const ll INF = 999999999999LL;vector<long long> fact, fact_inv, inv;/* init_nCk :二項係数のための前処理計算量:O(n)*/template <typename T>void input(vector<T> &v){rep(i,v.size()){cin>>v[i];}return;}void init_nCk(int SIZE) {fact.resize(SIZE + 5);fact_inv.resize(SIZE + 5);inv.resize(SIZE + 5);fact[0] = fact[1] = 1;fact_inv[0] = fact_inv[1] = 1;inv[1] = 1;for (int i = 2; i < SIZE + 5; i++) {fact[i] = fact[i - 1] * i % MOD;inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;}}/* nCk :MODでの二項係数を求める(前処理 int_nCk が必要)計算量:O(1)*/long long nCk(int n, int k) {assert(!(n < k));assert(!(n < 0 || k < 0));return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;}long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}ll POW(ll a,ll n){long long res = 1;while (n > 0) {if (n & 1) res = res * a;a = a * a;n >>= 1;}return res;}int main() {int n;cin>>n;vector<string> v(n);vector<ll> l(n);vector<ll> r(n);rep(i,n){cin >> v[i] >> l[i] >> r[i];}int q;cin>>q;vector<ll> a(q);vector<ll> b(q);vector<string> c(q);vector<ll> d(q);rep(i,q){ll aa;cin>>aa;a[i] = aa;if(aa==1){ll bb;string cc;cin>> cc >> bb;c[i] = cc;b[i] = bb;}else if(aa==2){cin>>b[i];}else{cin>>c[i]>>b[i]>>d[i];}}set<ll> st;rep(i,n){st.insert(2*l[i]);st.insert(2*r[i]+1);}rep(i,q){if(a[i]==3){st.insert(2*b[i]);st.insert(2*d[i]+1);}}vector<ll> t;for(auto u : st){t.push_back(u);}map<ll,ll> mp;rep(i,t.size()){mp[t[i]] = i;}map<string,set<pair<ll,ll>>> ps;rep(i,n){ps[v[i]].insert(pair(r[i],l[i]));}fenwick_tree<ll> fw(t.size()+1);rep(i,n){fw.add((int)(mp[l[i]*2]),1LL);fw.add((int)(mp[r[i]*2+1]),-1LL);}//rep(j,t.size()){cout << fw.sum(0,j+1) << " ";}cout<<endl;rep(i,q){if(a[i]==1){if(ps[c[i]].empty()||(ps[c[i]].lower_bound(pair(b[i],0)))==ps[c[i]].end()||(*(ps[c[i]].lower_bound(pair(b[i],0)))).second>b[i]){cout << "No" << endl;}else{cout<<"Yes"<<endl;}}else if(a[i]==2){cout << fw.sum(0,mp[*(upper_bound(all(t),b[i]*2))]) << endl;}else{ps[c[i]].insert(pair(d[i],b[i]));fw.add((int)(mp[b[i]*2]),1LL);fw.add((int)(mp[d[i]*2+1]),-1LL);}//rep(j,t.size()){cout << fw.sum(0,j+1) << " ";}cout<<endl;}}