結果
| 問題 |
No.2421 entersys?
|
| コンテスト | |
| ユーザー |
new_textfile
|
| 提出日時 | 2023-08-12 15:10:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 5,187 bytes |
| コンパイル時間 | 2,846 ms |
| コンパイル使用メモリ | 232,500 KB |
| 最終ジャッジ日時 | 2025-02-16 05:49:22 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// #include <atcoder/modint>
// #include <atcoder/segtree>
#include <atcoder/lazysegtree>
// #include <atcoder/dsu>
// #include <atcoder/scc>
using namespace atcoder;
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef priority_queue<pll, vpll, function<bool(pll,pll)> > pqpll;
typedef priority_queue<ll, vll, function<bool(pll,pll)> > pqll;
struct edge{ ll to, cost; edge(ll e_to,ll e_cost): to(e_to), cost(e_cost){} };
typedef vector<vector<edge>> Graph;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define LINF (1LL << 60)
#define INF (1 << 30)
#define fs first
#define sc second
#define EPS (ld)1e-10
#define ALL(a) a.begin(), a.end()
#define tcheck(a) if((clock() - start)/(ld)CLOCKS_PER_SEC >= a) break
#define debug(s) cout << #s << endl
#define debugval(x) cout << #x" = " << x << endl
template<typename T> ll sz(vector<T> &pos){ return (ll)pos.size(); }
template<typename T> ll sz(priority_queue<T, vector<T> > &que) {return (ll)que.size(); }
template<typename T> ll sz(priority_queue<T, vector<T>, greater<T> > &que) {return (ll)que.size(); }
ll sz(string &s) {return (ll)s.size(); }
template<typename T> void chmin(T &a, T b) { if(a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if(a < b) a = b; }
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }
// ll dx[4] = {0,-1,0,1},dy[4] = {-1,0,1,0};
ll dx[8] = {0,-1,-1,-1,0,1,1,1},dy[8] = {-1,-1,0,1,1,1,0,-1};
inline bool isinside(ll i,ll n){ return (i < n && i >= 0); }
pll op(pll a, pll b){return {a.fs + b.fs, a.sc + b.sc};}
pll e(){return {0,0}; }
pll mapping(ll f, pll x){ return {x.fs + x.sc*f, x.sc}; }
ll composition(ll f,ll g){return f+g;}
ll id(){return 0;}
int main(){
ll n;
cin >> n;
vector<pair<string,pll>> memo(n);
rep(i,0,n){
cin >> memo[i].fs >> memo[i].sc.fs >> memo[i].sc.sc;
memo[i].sc.fs--;
}
ll q; cin >> q;
vector<pair<array<ll,3>,string>> query(q);
rep(i,0,q){
ll op; cin >> op;
if(op == 1){
string x; cin >> x;
ll t; cin >> t;
t--;
query[i].fs = array<ll,3>({1,t,-1});
query[i].sc = x;
}
else if(op == 2){
ll t; cin >> t;
t--;
query[i].fs = array<ll,3>({2,t,-1});
}
else{
string x; cin >> x;
ll l,r; cin >> l >> r;
l--;
query[i].fs = array<ll,3>({3,l,r});
query[i].sc = x;
}
}
map<string,set<pll>> mp;
auto add = [&mp](string x, ll l, ll r){
auto& st = mp[x];
if(st.size() == 0){
st.emplace(LINF,LINF);
st.emplace(-LINF,-LINF);
}
st.emplace(l,r);
auto it = st.lower_bound(pll(l,r)); it--;
if(it->first <= l && l <= it->second){
l = min(l, it->first), r = max(r, it->second);
st.erase(it);
}
it = st.lower_bound(pll(l,r));
while(1){
if(l <= it->first && it->first <= r){
r = max(r, it->second);
it = st.erase(it);
}
else break;
}
st.insert(pll(l,r));
};
vll tmemo;
rep(i,0,n){
add(memo[i].fs, memo[i].sc.fs, memo[i].sc.sc);
tmemo.emplace_back(memo[i].sc.fs);
tmemo.emplace_back(memo[i].sc.sc);
}
rep(i,0,q){
if(query[i].fs[0] == 2) tmemo.emplace_back(query[i].fs[1]);
else if(query[i].fs[0] == 3){
tmemo.emplace_back(query[i].fs[1]);
tmemo.emplace_back(query[i].fs[2]);
}
}
sort(ALL(tmemo));
tmemo.erase(unique(ALL(tmemo)),tmemo.end());
map<ll,ll> zaatu;
rep(i,0,sz(tmemo)) zaatu[tmemo[i]] = i;
lazy_segtree<pll,op,e,ll,mapping,composition,id> seg(vector<pll>(sz(tmemo)+1,{0,1}));
rep(i,0,n) seg.apply(zaatu[memo[i].sc.fs], zaatu[memo[i].sc.sc],1);
rep(i,0,q){
if(query[i].fs[0] == 1){
ll t = query[i].fs[1];
auto& st = mp[query[i].sc];
if(st.size() == 0) cout << "No" << endl;
else{
auto it = st.lower_bound(pll(t, LINF)); it--;
if(it->first <= t && t <= it->second) cout << "Yes" << endl;
else cout << "No" << endl;
}
}
else if(query[i].fs[0] == 2){
auto [op,t,_] = query[i].fs;
cout << seg.get(zaatu[t]).fs << endl;
}
else if(query[i].fs[0] == 3){
auto [arr,x] = query[i];
auto [op,l,r] = arr;
add(x,l,r);
seg.apply(zaatu[l],zaatu[r],1);
}
}
}
new_textfile