結果

問題 No.2421 entersys?
ユーザー Ping Chung ChangPing Chung Chang
提出日時 2023-09-04 15:12:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 487 ms / 3,000 ms
コード長 2,198 bytes
コンパイル時間 2,806 ms
コンパイル使用メモリ 191,556 KB
実行使用メモリ 59,048 KB
最終ジャッジ日時 2023-09-04 15:12:20
合計ジャッジ時間 12,288 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
30,032 KB
testcase_01 AC 12 ms
30,108 KB
testcase_02 AC 13 ms
30,392 KB
testcase_03 AC 12 ms
30,004 KB
testcase_04 AC 13 ms
30,176 KB
testcase_05 AC 13 ms
30,144 KB
testcase_06 AC 13 ms
30,196 KB
testcase_07 AC 13 ms
30,192 KB
testcase_08 AC 13 ms
30,376 KB
testcase_09 AC 14 ms
30,324 KB
testcase_10 AC 12 ms
30,320 KB
testcase_11 AC 373 ms
50,584 KB
testcase_12 AC 411 ms
51,476 KB
testcase_13 AC 386 ms
50,884 KB
testcase_14 AC 381 ms
51,060 KB
testcase_15 AC 406 ms
50,624 KB
testcase_16 AC 377 ms
52,312 KB
testcase_17 AC 376 ms
53,396 KB
testcase_18 AC 383 ms
52,568 KB
testcase_19 AC 390 ms
52,576 KB
testcase_20 AC 383 ms
52,672 KB
testcase_21 AC 375 ms
50,716 KB
testcase_22 AC 273 ms
48,784 KB
testcase_23 AC 487 ms
57,500 KB
testcase_24 AC 467 ms
58,992 KB
testcase_25 AC 461 ms
59,048 KB
testcase_26 AC 304 ms
46,896 KB
testcase_27 AC 279 ms
45,588 KB
testcase_28 AC 278 ms
45,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>

struct Q{
	ll id,tp,l,r;
	Q(){}
	Q(ll ii,ll tt,ll s,ll e){
		id = ii,tp = tt,l = s,r = e;
	}
};

const ll mxn = 5e5+10;
const ll inf = 1e9+10;
ll bit[mxn];
vector<ll> all;
map<string,int> mp;
set<pll> st[mxn];
vector<Q> req;

void modify(int p,int v){
	for(;p<mxn;p+=p&-p)bit[p] += v;
	return;
}

ll getval(int p){
	int re = 0;
	for(;p>0;p-= p&-p)re += bit[p];
	return re;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i = 0;i<n;i++){
		string s;
		ll a,b;
		cin>>s>>a>>b;
		if(mp.find(s) == mp.end()){
			mp[s] = mp.size()+1;
		}
		all.push_back(a);
		all.push_back(b);
		req.push_back(Q(mp[s],3,a,b));
	}
	int q;
	cin>>q;
	for(int i = 0;i<q;i++){
		int t;
		cin>>t;
		if(t == 1){
			string s;
			int k;
			cin>>s>>k;
			if(mp.find(s) == mp.end()){
				mp[s] = mp.size()+1;
			}
			req.push_back(Q(i+n,1,mp[s],k));
			all.push_back(k);
		}
		else if(t==2){
			int k;
			cin>>k;
			req.push_back(Q(i+n,2,k,k));
			all.push_back(k);
		}
		else{
			string s;
			int a,b;
			cin>>s>>a>>b;
			all.push_back(a);all.push_back(b);
			if(mp.find(s) == mp.end()){
				mp[s] = mp.size()+1;
			}
			req.push_back(Q(mp[s],3,a,b));
		}
	}

	all.push_back(0);
	sort(all.begin(),all.end());
	all.erase(unique(all.begin(),all.end()),all.end());
	for(auto &i:req){
		if(i.tp == 3){
			i.l = lower_bound(all.begin(),all.end(),i.l)-all.begin();
			i.r = lower_bound(all.begin(),all.end(),i.r)-all.begin();
			st[i.id].insert({i.l,i.r});
			modify(i.l,1);
			modify(i.r+1,-1);
		}
		else if(i.tp == 1){
			i.r = lower_bound(all.begin(),all.end(),i.r)-all.begin();
			auto it = st[i.l].upper_bound(make_pair(i.r,inf));
			if(it != st[i.l].begin()){
				it--;
				if(it->fs <= i.r&&it->sc>=i.r)cout<<"Yes\n";
				else cout<<"No\n";
			}
			else cout<<"No\n";
		}
		else{
			i.l = lower_bound(all.begin(),all.end(),i.l)-all.begin();
			cout<<getval(i.l)<<'\n';
		}
	}
	return 0;
}
0