結果

問題 No.2421 entersys?
ユーザー Ping Chung ChangPing Chung Chang
提出日時 2023-09-04 15:07:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,224 bytes
コンパイル時間 2,304 ms
コンパイル使用メモリ 192,572 KB
実行使用メモリ 64,488 KB
最終ジャッジ日時 2023-09-04 15:07:46
合計ジャッジ時間 14,290 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
29,984 KB
testcase_01 AC 12 ms
30,076 KB
testcase_02 AC 14 ms
30,312 KB
testcase_03 AC 12 ms
30,116 KB
testcase_04 AC 12 ms
30,164 KB
testcase_05 AC 13 ms
30,264 KB
testcase_06 AC 13 ms
30,232 KB
testcase_07 AC 14 ms
30,156 KB
testcase_08 AC 14 ms
30,268 KB
testcase_09 AC 15 ms
30,376 KB
testcase_10 AC 13 ms
30,308 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 414 ms
55,520 KB
testcase_23 WA -
testcase_24 AC 643 ms
63,340 KB
testcase_25 AC 630 ms
64,224 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
		}
		st[mp[s]].insert({a,b});
		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