Submission #202083

#TimeUsernameProblemLanguageResultExecution timeMemory
202083DavidDamianCrayfish scrivener (IOI12_scrivener)C++11
60 / 100
247 ms17656 KiB
#include<bits/stdc++.h> using namespace std; int node[1000006]; int NEXT_FREE_INDEX=1; int n=1; int id[1000006]; char letter[1000006]; int p[1000006]; int len; int cont=0; void Init() { len=-1; id[0]=-1; } void TypeLetter(char L) { cont++; node[n]=NEXT_FREE_INDEX; id[NEXT_FREE_INDEX]=id[ node[n-1] ]+1; letter[NEXT_FREE_INDEX]=L; p[NEXT_FREE_INDEX]=node[n-1]; NEXT_FREE_INDEX++; n++; } void UndoCommands(int U) { cont++; node[n]=node[n-U-1]; n++; } vector<char> A; bool copied=false; char GetLetter(int P) { cont++; if(cont<=5000){ int k=node[n-1]; while(id[k]>P){ k=p[k]; } return letter[k]; } else if(!copied){ int k=node[n-1]; while(id[k]>=0){ A.push_back(letter[k]); k=p[k]; } reverse(A.begin(),A.end()); copied=true; return A[P]; } else return A[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...