제출 #456142

#제출 시각아이디문제언어결과실행 시간메모리
456142KhizriCrayfish scrivener (IOI12_scrivener)C++17
60 / 100
211 ms262148 KiB
#include <bits/stdc++.h>
#define pb push_back
#define F first																 
#define S second 
#define all(v) (v).begin(),(v).end()
using namespace std;
const int mxn=1e6+5;
int k=0;
vector<pair<int,int>>vt;
char last;
char alp[30];
string s;
bool y=true;
map<int,string>arr;
bool qq[mxn];
void Init() {
	char q='a';
	for(int i=0;i<26;i++){
		alp[i]=q;
		q++;
	}
}

void TypeLetter(char L) {
	y=false;
	int x=L-'a';
	vt.pb({1,x});
}

void UndoCommands(int U) {
	y=false;
	vt.pb({2,U});
}

char GetLetter(int P) {
	if(!y){
		y=true;
		s="";
		int ind=vt.size()-1;
		bool w=true;
		while(ind>=0){
			if(qq[ind]){
				string a=s;
				reverse(all(a));
				s=arr[ind]+a;
				w=false;
				break;
			}
			int a=vt[ind].F,b=vt[ind].S;
			if(a==1){
				s+=alp[b];
				ind--;
			}
			else{
				ind=ind-b-1;
			}
		}
		ind=vt.size()-1;
		if(w){
			reverse(all(s));
		}
		qq[ind]=true;
		arr[ind]=s;
	}
	return s[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...