Submission #957937

#TimeUsernameProblemLanguageResultExecution timeMemory
957937bmh123456789asdfMonkey and Apple-trees (IZhO12_apple)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #pragma GCC optimize("O3") #define int long long using namespace std; const int N = 12345; struct Node { int sum, lazy, tl, tr, l, r; Node() : sum(0), lazy(0), l(-1), r(-1) {} }; Node segtree[64 * N]; int cnt = 2; vonode pushlazy(int node) { if(segtree[node].lazy) { segtree[node].sum = segtree[node].tr - segtree[node].tl + 1; int mnode = (segtree[node].tr + segtree[node].tl) / 2; if(segtree[node].l == -1) { segtree[node].l = cnt++; segtree[cnt].tl = segtree[node].tl; segtree[cnt].tr = mnode; } if(segtree[node].r == -1) { segtree[node].r = cnt++; segtree[cnt].tl = mnode + 1; segtree[cnt].tr = segtree[node].tr; } segtree[segtree[node].l].lazy = segtree[segtree[node].r].lazy = 1; segtree[node].lazy = 0; } } vonode update(int node,int l,int r) { pushlazy(node); if(l == segtree[node].tl && r == segtree[node].tr) { segtree[node].lazy = 1; pushlazy(node); } else { int mnode = (segtree[node].tr + segtree[node].tl) / 2; if(segtree[node].l == -1) { segtree[node].l = cnt++; segtree[cnt].tl = segtree[node].tl; segtree[cnt].tr = mnode; } if(segtree[node].r == -1) { segtree[node].r = cnt++; segtree[cnt].tl = mnode + 1; segtree[cnt].tr = segtree[node].tr; } if(l > mnode) update(segtree[node].r, l, r); else if(r <= mnode) update(segtree[node].l, l, r); else { update(segtree[node].l, l, mnode); update(segtree[node].r, mnode + 1, r); } pushlazy(segtree[node].l); pushlazy(segtree[node].r); segtree[node].sum = segtree[segtree[node].l].sum + segtree[segtree[node].r].sum; } } int query(int node,int l,int r) { pushlazy(node); if(l == segtree[node].tl && r == segtree[node].tr) return segtree[node].sum; else { int mnode = (segtree[node].tr + segtree[node].tl) / 2; if(segtree[node].l == -1) { segtree[node].l = cnt++; segtree[cnt].tl = segtree[node].tl; segtree[cnt].tr = mnode; } if(segtree[node].r == -1) { segtree[node].r = cnt++; segtree[cnt].tl = mnode + 1; segtree[cnt].tr = segtree[node].tr; } if(l > mnode) return query(segtree[node].r, l, r); else if(r <= mnode) return query(segtree[node].l, l, r); else return query(segtree[node].l, l, mnode) + query(segtree[node].r, mnode + 1, r); } } int32_t main() { // freopen("f.in", "r" ,stdin); // freopen("f.out", "w" ,stdout); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int m, d, x, y, c = 0; segtree[1].sum = 0; segtree[1].lazy = 0; segtree[1].tl = 1; segtree[1].tr = 1e9; cin >> m; for(int i = 1; i <= m; i++) { cin >> d >> x >> y; if(d == 1) { c = query(1, x + c, y + c); cout << c <<'\n'; } else update(1, x + c, y + c); } }

Compilation message (stderr)

apple.cpp:16:1: error: 'vonode' does not name a type
   16 | vonode pushlazy(int node)
      | ^~~~~~
apple.cpp:39:1: error: 'vonode' does not name a type
   39 | vonode update(int node,int l,int r)
      | ^~~~~~
apple.cpp: In function 'long long int query(long long int, long long int, long long int)':
apple.cpp:79:5: error: 'pushlazy' was not declared in this scope
   79 |     pushlazy(node);
      |     ^~~~~~~~
apple.cpp: In function 'int32_t main()':
apple.cpp:129:14: error: 'update' was not declared in this scope
  129 |         else update(1, x + c, y + c);
      |              ^~~~~~