Submission #59797609


Source Code Expand

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

int main(){
	int N,Q;
	cin >> N >> Q;
	vector<int>cnt(N,1);
	set<pair<int,int>>s;
	for(int i=0;i<N;i++)s.insert({i,i});
	s.insert({-1,2e9});
	s.insert({N,2e9});
	
	while(Q--){
		int t;
		cin >> t;
		if(t==1){
			int x,c;
			cin >> x >> c;
			x--,c--;
			auto it=s.lower_bound({x,2e9});
			auto[R,Rc]=*it;
			auto[L,Mc]=*--it;
			auto[_,Lc]=*--it;
			cnt[Mc]-=R-L;
			cnt[c]+=R-L;
			it++;
			it=s.erase(it);//[R,Rc]
			if(c==Rc){
				it=s.erase(it);
			}
			if(c==Lc){
				//pass
			}else{
				s.insert({L,c});
			}
		}else{
			int c;
			cin >> c;
			c--;
			cout << cnt[c] << endl;
		}
	}
}

Submission Info

Submission Time
Task E - 1D Bucket Tool
User kyopro_friends
Language C++ 20 (gcc 12.2)
Score 450
Code Size 681 Byte
Status AC
Exec Time 417 ms
Memory 28612 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 1
AC × 18
Set Name Test Cases
Sample sample_01.txt
All hand.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, sample_01.txt
Case Name Status Exec Time Memory
hand.txt AC 5 ms 3660 KiB
random_01.txt AC 146 ms 3512 KiB
random_02.txt AC 200 ms 3664 KiB
random_03.txt AC 213 ms 3560 KiB
random_04.txt AC 230 ms 3584 KiB
random_05.txt AC 200 ms 28440 KiB
random_06.txt AC 214 ms 28440 KiB
random_07.txt AC 261 ms 28612 KiB
random_08.txt AC 415 ms 28392 KiB
random_09.txt AC 415 ms 28476 KiB
random_10.txt AC 416 ms 28472 KiB
random_11.txt AC 411 ms 28384 KiB
random_12.txt AC 417 ms 28384 KiB
random_13.txt AC 204 ms 5856 KiB
random_14.txt AC 206 ms 5844 KiB
random_15.txt AC 207 ms 5856 KiB
random_16.txt AC 207 ms 6008 KiB
sample_01.txt AC 1 ms 3352 KiB