Submission #237344

#TimeUsernameProblemLanguageResultExecution timeMemory
237344T0p_Crayfish scrivener (IOI12_scrivener)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; struct node { int l, r; char c; }; int all, ver; int root[1000005]; node seg[23000000]; int build(int l, int r) { int now = ++all; if(l == r) return now; int mid = (l+r)>>1; int L = build(l, mid), R = build(mid+1, r); seg[now] = {0, L, R}; return now; } void Init() { root[0] = build(1, 1000000); } int update(int idx, int l, int r, int p, char c) { if(!(l <= p && p <= r)) return idx; int now = ++all; if(l == r) { seg[now].c = c; return now; } int mid = (l+r)>>1; int L = update(seg[idx].l, l, mid, p, c), R = update(seg[idx].r, mid+1, r, p, c); seg[now].l = L, seg[now].r = R, seg[now].v = seg[L].v+seg[R].v; return now; } void TypeLetter(char L) { ver++; root[ver] = update(root[ver-1], 1, 1000000, seg[root[ver-1]].v+1, L); } void UndoCommands(int U) { ver++; root[ver] = root[ver-U-1]; } char query(int idx, int l, int r, int p) { if(l == r) return seg[idx].c; int mid = (l+r)>>1; return (p <= mid) ? query(seg[idx].l, l, mid, p) : query(seg[idx].r, mid+1, r, p); } char GetLetter(int P) { return query(root[ver], 1, 1000000, P+1); }

Compilation message (stderr)

scrivener.cpp: In function 'int build(int, int)':
scrivener.cpp:20:21: warning: narrowing conversion of 'R' from 'int' to 'char' inside { } [-Wnarrowing]
  seg[now] = {0, L, R};
                     ^
scrivener.cpp: In function 'int update(int, int, int, int, char)':
scrivener.cpp:38:43: error: 'struct node' has no member named 'v'
  seg[now].l = L, seg[now].r = R, seg[now].v = seg[L].v+seg[R].v;
                                           ^
scrivener.cpp:38:54: error: 'struct node' has no member named 'v'
  seg[now].l = L, seg[now].r = R, seg[now].v = seg[L].v+seg[R].v;
                                                      ^
scrivener.cpp:38:63: error: 'struct node' has no member named 'v'
  seg[now].l = L, seg[now].r = R, seg[now].v = seg[L].v+seg[R].v;
                                                               ^
scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:44:63: error: 'struct node' has no member named 'v'
  root[ver] = update(root[ver-1], 1, 1000000, seg[root[ver-1]].v+1, L);
                                                               ^