Submission #79047

#TimeUsernameProblemLanguageResultExecution timeMemory
79047TAMREFCrayfish scrivener (IOI12_scrivener)C++11
5 / 100
34 ms15312 KiB
#include <bits/stdc++.h> using namespace std; const int mx = 1e6 + 5; const int lg = 20; struct node{ node(){} node(node *c, char x, int i) : c(c),x(x),i(i) {} node *p[lg], *c; char x; int i; void show(){ printf("x = %c, i = %d, c = %p\n",x,i,c); } }; node N[mx]; int n; void Init() { } void TypeLetter(char L) { //printf("Type(%c)\n",L); printf(""); N[n] = node(nullptr, L, !n ? 0 : N[n-1].i + 1); node &x = N[n]; x.p[0] = (!n ? nullptr : N + n - 1); for(int j = 1; j < lg; j++){ if(x.p[j-1] != nullptr) x.p[j] = x.p[j-1] -> p[j-1]; else break; } x.c = &x; //N[n].show(); ++n; } void UndoCommands(int U) { //printf("Undo(%d)\n",U); node p = N[n - 1 - U]; N[n] = node(p.c, 'U', p.i); node &x = N[n]; x.p[0] = &p; for(int j = 1; j < lg; j++){ if(x.p[j-1]) x.p[j] = x.p[j-1] -> p[j-1]; } //N[n].show(); ++n; } char GetLetter(int P) { //printf("Get(%d)\n",P); node *b = N + n - 1; if(b->i < P) puts("BAAM!"); for(int j = lg; j >= 0; j--){ if(b->i == P) return b->c->x; if(b->p[j] && b->p[j]->i >= P) b = b->p[j]; } //printf("bi : %d\n",b->i); //puts("asdf"); return b->i == P ? b->c->x : b->p[0]->c->x; }

Compilation message (stderr)

scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:24:14: warning: zero-length gnu_printf format string [-Wformat-zero-length]
     printf("");
              ^
#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...