100932024-03-26 18:05:40111Génsebészcpp17Time limit exceeded 80/100208ms30164 KiB
#ifdef ONLINE_JUDGE
#include "grader.h"
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T, typename V>
using ordered_map = tree<T, V, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_map<double,char>s;
ordered_set<double>z[200];

void Kezd(string S){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n=S.size();
	s[-1]=0;
	for(int i=0;i<n;i++){
		s[1e9*i/n]=S[i];
		z[S[i]].insert(1e9*i/n);
	}
	s[1e9]=0;
}

void Beszur(int i,char x){
	auto it=s.find_by_order(i);
	double y=(it->first+next(it)->first)/2;
	s[y]=x;
	z[x].insert(y);
}

void Mutal(int i,char x){
	auto it=s.find_by_order(i);
	double y=it->first;
	z[it->second].erase(y);
	s[y]=x;
	z[x].insert(y);
}

void Kivag(int i,int j){
	auto it1=s.find_by_order(i);
	auto it2=s.find_by_order(j+1);
	while(it1!=it2){
		z[it1->second].erase(it1->first);
		it1=s.erase(it1);
	}
}

int Szamlal(int i,int j,char x){
	auto it1=s.find_by_order(i);
	auto it2=s.find_by_order(j+1);
	return z[x].order_of_key(it2->first)-z[x].order_of_key(it1->first);
}

string Eredmeny(){
	string ans;
	ans.reserve(s.size()-2);
	for(auto [_,x]:s){
		if(x==0)continue;
		ans+=x;
	}
	return ans;
}

#ifndef ONLINE_JUDGE
int main(){
	freopen("be2.txt","r",stdin);
	string S;
	cin>>S;
	Kezd(S);
	while(true){
		int o;
		cin>>o;
		if(o==0){
			break;
		}
		if(o==1){
			int i;
			char x;
			cin>>i>>x;
			Beszur(i,x);
		}
		if(o==2){
			int i;
			char x;
			cin>>i>>x;
			Mutal(i,x);
		}
		if(o==3){
			int i,j;
			cin>>i>>j;
			Kivag(i,j);
		}
		if(o==4){
			int i,j;
			char x;
			cin>>i>>j>>x;
			int res=Szamlal(i,j,x);
			int ans;
			cin>>ans;
			ans--;
			if(res!=ans){
				cout<<"got "<<res<<'\n';
				cout<<"exp "<<ans<<'\n';
				return 1;
			}
		}
		if(o==5){
			string res=Eredmeny();
			string ans;
			cin>>ans;
			ans.pop_back();
			if(res!=ans){
				cout<<"got "<<res<<'\n';
				cout<<"exp "<<ans<<'\n';
				return 1;
			}
		}
	}
	return 0;
}
#endif
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1980 KiB
2Accepted3ms2568 KiB
subtask230/30
3Accepted3ms2672 KiB
4Accepted3ms2896 KiB
5Accepted3ms3000 KiB
6Accepted4ms3292 KiB
7Accepted4ms3632 KiB
8Accepted50ms11044 KiB
subtask330/30
9Accepted3ms3616 KiB
10Accepted3ms3596 KiB
11Accepted3ms3868 KiB
12Accepted3ms4116 KiB
13Accepted4ms4300 KiB
14Accepted71ms14452 KiB
subtask420/20
15Accepted3ms4148 KiB
16Accepted3ms4420 KiB
17Accepted3ms4324 KiB
18Accepted3ms4328 KiB
19Accepted94ms17148 KiB
subtask50/20
20Accepted4ms5032 KiB
21Accepted6ms5288 KiB
22Accepted7ms5800 KiB
23Accepted13ms7036 KiB
24Time limit exceeded208ms30164 KiB