Submission #398646

#TimeUsernameProblemLanguageResultExecution timeMemory
398646hoaphat1Crayfish scrivener (IOI12_scrivener)C++17
0 / 100
160 ms262148 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e6 + 3; struct node { node* L; node* R; char c; int cnt = 0; void apply(node* x) { L = x->L; R = x->R; c = x->c; cnt = x->cnt; } }; node* s[N]; int n = 0; struct segtree { void build(node*& R, int l, int r) { R = new node{}; if (l == r) { return ; } int mid = l + r >> 1; build(R->L, l, mid); build(R->R, mid + 1, r); } node* modify(node* R, int l, int r, int pos, char c) { node* res = new node{}; if (l == r) { res->c = c; res->cnt = 1; return res; } res->L = R->L; res->R = R->R; int mid = l + r >> 1; if (pos <= mid) res->L = modify(R->L, l, mid, pos, c); else res->R = modify(R->R, mid + 1, r, pos, c); res->cnt = res->L->cnt + res->R->cnt; return res; } char get(node* R, int l, int r, int pos) { if (l == r) return R->c; int mid = l + r >> 1; if (pos <= mid) return get(R->L, l, mid, pos); return get(R->R, mid + 1, r, pos); } }; segtree Tree; string st[N]; void Init() { /*s[0] = new node{}; Tree.build(s[0], 0, N - 1);*/ } void TypeLetter(char L) { //s[++n] = Tree.modify(s[n - 1], 0, N - 1, s[n - 1]->cnt, L); st[++n] = st[n - 1] + L; } void UndoCommands(int m) { st[++n] = st[n - m - 1]; //s[++n] = new node{}; //s[n]->apply(s[n - m - 1]); } char GetLetter(int p) { return st[n][p]; //return Tree.get(s[n], 0, N - 1, p); }

Compilation message (stderr)

scrivener.cpp: In member function 'void segtree::build(node*&, int, int)':
scrivener.cpp:27:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   27 |   int mid = l + r >> 1;
      |             ~~^~~
scrivener.cpp: In member function 'node* segtree::modify(node*, int, int, int, char)':
scrivener.cpp:40:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   40 |   int mid = l + r >> 1;
      |             ~~^~~
scrivener.cpp: In member function 'char segtree::get(node*, int, int, int)':
scrivener.cpp:48:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   48 |   int mid = l + r >> 1;
      |             ~~^~~
scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:63:5: warning: operation on 'n' may be undefined [-Wsequence-point]
   63 |  st[++n] = st[n - 1] + L;
      |     ^~~
scrivener.cpp:63:5: warning: operation on 'n' may be undefined [-Wsequence-point]
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:67:5: warning: operation on 'n' may be undefined [-Wsequence-point]
   67 |  st[++n] = st[n - m - 1];
      |     ^~~
scrivener.cpp:67:5: warning: operation on 'n' may be undefined [-Wsequence-point]
#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...