Submission #59240

#TimeUsernameProblemLanguageResultExecution timeMemory
59240TadijaSebezCrayfish scrivener (IOI12_scrivener)C++11
100 / 100
736 ms197700 KiB
#include <stdio.h> #include <vector> #include <algorithm> using namespace std; const int N=1000050; const int M=20*N; int ls[M],rs[M],root[N],tsz; char ch[M]; void Set(int p, int &c, int ss, int se, int qi, char s) { c=++tsz;ls[c]=ls[p];rs[c]=rs[p];ch[c]=s; if(ss==se) return; int mid=ss+se>>1; if(qi<=mid) Set(ls[p],ls[c],ss,mid,qi,s); else Set(rs[p],rs[c],mid+1,se,qi,s); } char Get(int c, int ss, int se, int qi) { if(ss==se) return ch[c]; int mid=ss+se>>1; if(qi<=mid) return Get(ls[c],ss,mid,qi); else return Get(rs[c],mid+1,se,qi); } void Init(){} int cnt=0,sz[N]; void TypeLetter(char s) { cnt++;sz[cnt]=sz[cnt-1]+1; root[cnt]=root[cnt-1]; Set(root[cnt],root[cnt],1,N,sz[cnt],s); } void UndoCommands(int x) { cnt++; root[cnt]=root[cnt-x-1]; sz[cnt]=sz[cnt-x-1]; } char GetLetter(int x){ return Get(root[cnt],1,N,x+1);}

Compilation message (stderr)

scrivener.cpp: In function 'void Set(int, int&, int, int, int, char)':
scrivener.cpp:13:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid=ss+se>>1;
          ~~^~~
scrivener.cpp: In function 'char Get(int, int, int, int)':
scrivener.cpp:20:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid=ss+se>>1;
          ~~^~~
#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...