結果
問題 | No.2421 entersys? |
ユーザー |
![]() |
提出日時 | 2023-08-12 14:01:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,713 bytes |
コンパイル時間 | 4,391 ms |
コンパイル使用メモリ | 248,452 KB |
実行使用メモリ | 34,652 KB |
最終ジャッジ日時 | 2024-11-19 17:03:19 |
合計ジャッジ時間 | 16,741 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 WA * 1 |
ソースコード
#include <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int main(){ int n,q; cin>>n; vector<string> x(n); vector<int> l(n),r(n); vector<int> t; rep(i,n){ cin>>x[i]>>l[i]>>r[i]; r[i]++; t.push_back(l[i]); t.push_back(r[i]); } cin>>q; vector<int> type(q); vector<string> qx(q); vector<int> a(q),b(q); rep(i,q){ cin>>type[i]; if(type[i]==1){ cin>>qx[i]; cin>>a[i]; t.push_back(a[i]); } if(type[i]==2){ cin>>a[i]; t.push_back(a[i]); } if(type[i]==3){ cin>>qx[i]; cin>>a[i]>>b[i]; b[i]++; t.push_back(a[i]); t.push_back(b[i]); } } sort(t.begin(),t.end()); t.erase(unique(t.begin(),t.end())); fenwick_tree<long long> F(t.size()+5); map<string,map<int,int>> mp; rep(i,n){ mp[x[i]][l[i]] = r[i]; int d = distance(t.begin(),lower_bound(t.begin(),t.end(),l[i])); F.add(d,1); d = distance(t.begin(),lower_bound(t.begin(),t.end(),r[i])); F.add(d,-1); } rep(i,q){ if(type[i]==1){ auto it = mp[qx[i]].upper_bound(a[i]); if(it==mp[qx[i]].begin())cout<<"No"<<endl; else{ it--; if(it->first <= a[i] && a[i] < it->second)cout<<"Yes"<<endl; else cout<<"No"<<endl; } } if(type[i]==2){ int d = distance(t.begin(),lower_bound(t.begin(),t.end(),a[i])); cout<<F.sum(0,d+1)<<endl; } if(type[i]==3){ int d = distance(t.begin(),lower_bound(t.begin(),t.end(),a[i])); F.add(d,1); d = distance(t.begin(),lower_bound(t.begin(),t.end(),b[i])); F.add(d,-1); mp[qx[i]][a[i]] = b[i]; } } return 0; }