Submission #757162

#TimeUsernameProblemLanguageResultExecution timeMemory
757162Desh03Crayfish scrivener (IOI12_scrivener)C++17
34 / 100
519 ms262144 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 1; struct node { int val; node *left, *right; node() : left(NULL), right(NULL) { }; node(const int &x) : val(x), left(NULL), right(NULL) { }; node(node* l, node* r) : left(l), right(r) { }; }; struct Persistent_Segment_Tree { node *root; Persistent_Segment_Tree() : root(NULL) { }; node* upd(node* v, int l, int r, int u, int x) { if (l == r) return new node(x); if (!v) v = new node(); int m = l + r >> 1; if (u <= m) v = new node(upd(v->left, l, m, u, x), v->right); else v = new node(v->left, upd(v->right, m + 1, r, u, x)); return v; } int qry(node* &v, int l, int r, int u) { if (l == r) return v->val; int m = l + r >> 1; if (u <= m) return qry(v->left, l, m, u); return qry(v->right, m + 1, r, u); } void upd(int u, int x) { root = upd(root, 0, N, u, x); } int qry(int u) { return qry(root, 0, N, u); } }; vector<Persistent_Segment_Tree> st; int cur[N]; void Init() { st.push_back(Persistent_Segment_Tree()); } void TypeLetter(char L) { st.back().upd(cur[st.size() - 1]++, L - 'a'); cur[st.size()] = cur[st.size() - 1]; st.push_back(st.back()); } void UndoCommands(int U) { cur[st.size() - 1] = cur[st.size()] = cur[st.size() - U - 2]; st.back() = st[st.size() - U - 2]; st.push_back(st.back()); } char GetLetter(int P) { return 'a' + st.back().qry(P); }

Compilation message (stderr)

scrivener.cpp: In member function 'node* Persistent_Segment_Tree::upd(node*, int, int, int, int)':
scrivener.cpp:20:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   20 |         int m = l + r >> 1;
      |                 ~~^~~
scrivener.cpp: In member function 'int Persistent_Segment_Tree::qry(node*&, int, int, int)':
scrivener.cpp:27:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   27 |         int m = 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...