제출 #115572

#제출 시각아이디문제언어결과실행 시간메모리
115572faustaadp크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
0 / 100
915 ms92208 KiB
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
char last;

char hai[1010101];
pair<ll,ll> A[1010101];
ll te;
int p[20][1000001];
void cek()
{
	ll ii;
	for(ii=0;ii<te;ii++)
		cout<<ii<<" "<<char(A[ii].fi)<<" "<<A[ii].se<<"\n";
	cout<<"\n";
}
void Init() {}
void TypeLetter(char L) 
{
	ll bes=0,ii;
	if(te>0)
		bes=A[te-1].se+1;
	A[te]=mp(L,bes);
	hai[bes]=L;
	p[0][te]=te-1;
	for(ii=1;ii<20;ii++)
		p[ii][te]=p[ii-1][p[ii-1][te]];
	te++;
//	cek();
}

void UndoCommands(int U) 
{
	ll ii;
	A[te]=A[te-U-1];
	p[0][te]=p[0][te-U-1];
	for(ii=1;ii<20;ii++)
		p[ii][te]=p[ii-1][p[ii-1][te]];
	te++;
//	cek();
}

char GetLetter(int P) 
{
	ll ii,X=te-1;
	for(ii=19;ii>=0;ii--)
		if(A[p[ii][X]].se>=P)
			X=p[ii][X];
	return char(A[X].fi);
//	return hai[P];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...