結果

問題 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,957 ms
コンパイル使用メモリ 279,868 KB
実行使用メモリ 28,904 KB
最終ジャッジ日時 2024-04-30 08:47:37
合計ジャッジ時間 10,464 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
17,512 KB
testcase_01 AC 9 ms
10,368 KB
testcase_02 AC 17 ms
10,384 KB
testcase_03 AC 7 ms
10,352 KB
testcase_04 AC 10 ms
10,368 KB
testcase_05 AC 12 ms
10,480 KB
testcase_06 AC 14 ms
10,496 KB
testcase_07 AC 14 ms
10,496 KB
testcase_08 AC 16 ms
10,496 KB
testcase_09 AC 25 ms
10,496 KB
testcase_10 AC 11 ms
10,368 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

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