結果

問題 No.2421 entersys?
ユーザー aradarad
提出日時 2023-08-12 15:18:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 3,761 bytes
コンパイル時間 4,401 ms
コンパイル使用メモリ 278,716 KB
実行使用メモリ 41,004 KB
最終ジャッジ日時 2024-11-20 01:10:26
合計ジャッジ時間 78,466 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
32,200 KB
testcase_01 AC 9 ms
17,268 KB
testcase_02 AC 16 ms
17,312 KB
testcase_03 AC 7 ms
33,352 KB
testcase_04 AC 8 ms
17,184 KB
testcase_05 AC 12 ms
33,224 KB
testcase_06 AC 12 ms
17,308 KB
testcase_07 AC 11 ms
32,288 KB
testcase_08 AC 14 ms
32,552 KB
testcase_09 AC 22 ms
17,340 KB
testcase_10 AC 11 ms
17,316 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using P = pair<ll,ll>;
using VP = vector<P>;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define out(x) cout << x << endl
#define dout(x) cout << fixed << setprecision(10) << x << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)(x.size())
#define re0 return 0
#define pcnt __builtin_popcountll
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int inf = 1e9;
constexpr ll INF = 1e18;
//using mint = modint1000000007;
using mint = modint998244353;
int di[4] = {1,0,-1,0};
int dj[4] = {0,1,0,-1};

int main(){
    ll n;
    cin >> n;
    VP events;
    VL l(n+100001,-1),r(n+100001,-1),t(n+100001,-1),type(n+100001,-1),ans(n+100001,-1);
    VS x(n+100001);
    rep(i,n){
        cin >> x[i] >> l[i] >> r[i];
        events.emplace_back(l[i],i);
        events.emplace_back(r[i],i+2*inf);
    }
    ll q;
    cin >> q;
    ll sqq = sqrt(q);
    for(ll bl = 0;bl <= sqq+1;bl++){
        for(ll i = sqq*bl;i < sqq*(bl+1);i++){
            if(i >= q) break;
            cin >> type[i+n];
            if(type[i+n] == 1){
                cin >> x[i+n] >> t[i+n];
                events.emplace_back(t[i+n],i+n+inf);
            }
            if(type[i+n] == 2){
                cin >> t[i+n];
                events.emplace_back(t[i+n],i+n+inf);
            }
            if(type[i+n] == 3){
                cin >> x[i+n] >> l[i+n] >> r[i+n];
            }
        }
        sort(all(events));
        set<string> st;
        ll cnt = 0;
        for(auto e:events){
            auto [time,i] = e;
            if(time == INF) break;
            if(i < inf){
                //in
                st.insert(x[i]);
                cnt++;
            } else if(i < 2*inf){
                //check
                i -= inf;
                if(type[i] == 1){
                    if(st.count(x[i])){
                        ans[i] = 1;
                    } else {
                        ans[i] = 0;
                    }
                } else {
                    ans[i] = cnt;
                }
                
            } else {
                //out
                i -= 2*inf;
                st.erase(x[i]);
                cnt--;
            }
        }
        rep(i,sz(events)){
            if(inf <= events[i].second && events[i].second < 2*inf){
                events[i].first = INF;
            }
        }
        for(int i = sqq*bl;i < sqq*(bl+1);i++){
            if(i >= q) break;
            if(type[i+n] == 3) continue;
            for(int j = sqq*bl;j < i;j++){
                if(type[j+n] != 3) continue;
                if(l[j+n] <= t[i+n] && t[i+n] <= r[j+n]){
                    if(type[i+n] == 1 && x[i+n] == x[j+n]){
                        ans[i+n] = 1;
                    } else if(type[i+n] == 2){
                        ans[i+n]++;
                    }
                }
            }
        }
        for(int i = sqq*bl;i < sqq*(bl+1);i++){
            if(i >= q) break;
            if(type[i+n] == 3){
                events.emplace_back(l[i+n],i+n);
                events.emplace_back(r[i+n],i+n+2*inf);
            }
        }
    }
    for(int i = n;i < n+q;i++){
        if(type[i] == 1){
            if(ans[i] == 1) out("Yes");
            else out("No");
        }
        if(type[i] == 2){
            out(ans[i]);
        }
    }
}
0