結果

問題 No.2421 entersys?
ユーザー new_textfilenew_textfile
提出日時 2023-08-12 15:10:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 5,187 bytes
コンパイル時間 3,279 ms
コンパイル使用メモリ 243,016 KB
実行使用メモリ 92,572 KB
最終ジャッジ日時 2024-11-20 00:04:48
合計ジャッジ時間 20,993 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,248 KB
testcase_02 AC 6 ms
5,248 KB
testcase_03 AC 2 ms
5,248 KB
testcase_04 AC 3 ms
5,248 KB
testcase_05 AC 4 ms
5,248 KB
testcase_06 AC 4 ms
5,248 KB
testcase_07 AC 4 ms
5,248 KB
testcase_08 AC 5 ms
5,248 KB
testcase_09 AC 7 ms
5,248 KB
testcase_10 AC 4 ms
5,248 KB
testcase_11 AC 897 ms
72,580 KB
testcase_12 AC 898 ms
72,604 KB
testcase_13 AC 898 ms
72,580 KB
testcase_14 AC 906 ms
72,584 KB
testcase_15 AC 929 ms
72,528 KB
testcase_16 AC 930 ms
78,044 KB
testcase_17 AC 943 ms
77,880 KB
testcase_18 AC 917 ms
77,992 KB
testcase_19 AC 944 ms
77,840 KB
testcase_20 AC 960 ms
77,976 KB
testcase_21 AC 758 ms
58,096 KB
testcase_22 AC 851 ms
77,028 KB
testcase_23 AC 1,165 ms
92,496 KB
testcase_24 AC 1,159 ms
92,572 KB
testcase_25 AC 1,198 ms
92,556 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);
        }
    }
}
0