Submission #260268

#TimeUsernameProblemLanguageResultExecution timeMemory
260268youssefbou62Crayfish scrivener (IOI12_scrivener)C++14
26 / 100
251 ms9684 KiB
#include <bits/stdc++.h> #define pb push_back #define sz(x) (int)x.size() #define fi first #define se second using namespace std ; const int MAXN = 1e6+6 ; int state , cnt , par[MAXN][20]; // string ans[MAXN] ; vector<pair<int,int>> queries; void Init() { } // void new_state(int s){ // for(int i=1;i<19;i++){ // par[s][i] = par[par[s][i-1]][i-1]; // } // cerr << "current answer: " << ans[state] << endl; // } // int kth_anc(int u,int k){ // for(int i = 18 ; i >= 0 ; i-- ){ // if(k&(1<<i)){ // k-=(1<<i); // u = par[u][i] ; // } // } // return u; // } void TypeLetter(char L) { queries.pb({0,(L-'a')}); //new_state(state); } void UndoCommands(int U) { queries.pb({1,U}); } bool done = 0 ; string res ; void RES(){ done = 1; int nxt = -1 , del = 0 ; string ans =""; for(int i = sz(queries)-1 ; i >= 0 ; i-- ){ if( !del ){ if( queries[i].fi == 0 ){ ans.pb((char)(queries[i].se+'a')); }else{ nxt = i - queries[i].se ; del = 1 ; } } if(del&&nxt==i)del = 0 ; } reverse(ans.begin(),ans.end()); res = ans; } char GetLetter(int P) { if( !done )RES(); return res[P]; } // int main() { // Init(); // int cmd_num; // bool tmp = scanf("%d", &cmd_num); // assert(tmp == 1); // int i; // for (i = 0; i < cmd_num; i++) { // char cmd; // tmp = scanf(" %c", &cmd); // assert(tmp == 1); // if (cmd == 'T') { // char letter; // tmp = scanf(" %c", &letter); // assert(tmp == 1); // TypeLetter(letter); // } // else if (cmd == 'U') { // int number; // tmp = scanf("%d", &number); // assert(tmp == 1); // UndoCommands(number); // } // else if (cmd == 'P') { // int index; // char letter; // tmp = scanf("%d", &index); // assert(tmp == 1); // letter = GetLetter(index); // printf("%c\n", letter); // } // } // puts("Let's test for cheating!!"); // return 0; // }
#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...