Submission #768133

#TimeUsernameProblemLanguageResultExecution timeMemory
768133Dan4LifeCrayfish scrivener (IOI12_scrivener)C++17
100 / 100
411 ms148024 KiB
#include <bits/stdc++.h> using namespace std; const int mxN = (int)1e6; int IND=1,tot=0; char seg[mxN*160]; int num[mxN], ro[mxN]; int L[mxN*160], R[mxN*160]; int newChild(int p, char v){ int p2=++IND; L[p2]=L[p],R[p2]=R[p], seg[p2]=v; return p2; } int newParent(int l, int r){ int p = ++IND; L[p]=l, R[p]=r; return p; } int upd(int x, char v, int p, int l=0, int r=mxN){ if(!p) return p; int mid = (l+r)/2; if(l==r) return newChild(p,v); if(!L[p]) L[p]=++IND; if(!R[p]) R[p]=++IND; if(x<=mid) return newParent(upd(x,v,L[p],l,mid),R[p]); return newParent(L[p],upd(x,v,R[p],mid+1,r)); } int query(int x, int p, int l=0, int r=mxN){ if(l==r) return seg[p]; int mid = (l+r)/2; if(x<=mid) return query(x,L[p],l,mid); return query(x,R[p],mid+1,r); } void Init(){ ro[0]=1; } void TypeLetter(char L){ tot++,ro[tot]=upd(num[tot-1],L,ro[tot-1]), num[tot]=num[tot-1]+1; } void UndoCommands(int x){ tot++,ro[tot]=ro[tot-x-1], num[tot]=num[tot-x-1]; } char GetLetter(int x){ return query(x,ro[tot]); }

Compilation message (stderr)

scrivener.cpp: In function 'int upd(int, char, int, int, int)':
scrivener.cpp:14:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   14 |     if(!p) return p; int mid = (l+r)/2;
      |     ^~
scrivener.cpp:14:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   14 |     if(!p) return p; int mid = (l+r)/2;
      |                      ^~~
scrivener.cpp:16:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   16 |     if(!L[p]) L[p]=++IND; if(!R[p]) R[p]=++IND;
      |     ^~
scrivener.cpp:16:27: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   16 |     if(!L[p]) L[p]=++IND; if(!R[p]) R[p]=++IND;
      |                           ^~
scrivener.cpp: In function 'int query(int, int, int, int)':
scrivener.cpp:22:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   22 |     if(l==r) return seg[p]; int mid = (l+r)/2;
      |     ^~
scrivener.cpp:22:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   22 |     if(l==r) return seg[p]; int mid = (l+r)/2;
      |                             ^~~
#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...