100852024-03-26 17:46:53111Génsebészcpp17Wrong answer 30/100234ms18068 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){
	int n=S.size();
	s[-1]=0;
	for(int i=0;i<n;i++){
		s[i]=S[i];
		z[S[i]].insert(i);
	}
	s[n]=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);
	int 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;
	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
1Accepted3ms2092 KiB
2Accepted4ms2436 KiB
subtask230/30
3Accepted3ms2552 KiB
4Accepted3ms2780 KiB
5Accepted4ms3000 KiB
6Accepted4ms3320 KiB
7Accepted6ms3596 KiB
8Accepted72ms11228 KiB
subtask30/30
9Wrong answer3ms3800 KiB
10Wrong answer3ms3948 KiB
11Wrong answer3ms3916 KiB
12Wrong answer3ms3964 KiB
13Wrong answer3ms4268 KiB
14Accepted98ms14616 KiB
subtask40/20
15Wrong answer3ms4408 KiB
16Wrong answer3ms4424 KiB
17Wrong answer3ms4440 KiB
18Wrong answer3ms4728 KiB
19Accepted127ms17676 KiB
subtask50/20
20Wrong answer4ms5788 KiB
21Wrong answer6ms6256 KiB
22Wrong answer7ms6592 KiB
23Wrong answer12ms7720 KiB
24Time limit exceeded234ms18068 KiB