Submission #591571

#TimeUsernameProblemLanguageResultExecution timeMemory
591571stevancvCrayfish scrivener (IOI12_scrivener)C++14
100 / 100
439 ms185408 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; const int N = 1e6; int st[20 * N], lc[20 * N], rc[20 * N], root[N], tsz; void Add(int& node, int pnode, int l, int r, int x, int y) { node = ++tsz; if (l == r) {st[node] = y; return; } lc[node] = lc[pnode]; rc[node] = rc[pnode]; int mid = l + r >> 1; if (x <= mid) Add(lc[node], lc[pnode], l, mid, x, y); else Add(rc[node], rc[pnode], mid + 1, r, x, y); } int Get(int node, int l, int r, int p) { if (l == r) return st[node]; int mid = l + r >> 1; if (p <= mid) return Get(lc[node], l, mid, p); else return Get(rc[node], mid + 1, r, p); } int sz[N], ind; void TypeLetter(char c) { ind += 1; sz[ind] = sz[ind - 1] + 1; int br = c - 'a' + 1; Add(root[ind], root[ind - 1], 1, N, sz[ind], br); } void UndoCommands(int u) { ind += 1; u += 1; sz[ind] = sz[ind - u]; root[ind] = root[ind - u]; } char GetLetter(int p) { p += 1; int x = Get(root[ind], 1, N, p); return (char)(x + 'a' - 1); } void Init() {}

Compilation message (stderr)

scrivener.cpp: In function 'void Add(int&, int, int, int, int, int)':
scrivener.cpp:15:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   15 |     int mid = l + r >> 1;
      |               ~~^~~
scrivener.cpp: In function 'int Get(int, int, int, int)':
scrivener.cpp:21:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   21 |     int mid = l + r >> 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...