Submission #538359

#TimeUsernameProblemLanguageResultExecution timeMemory
538359fcwHappiness (Balkan15_HAPPINESS)C++17
Compilation error
0 ms0 KiB
using lint = long long; lint LIM = 1e12 + 10; struct node{ lint sum, lz; int l, r; node(): sum(0), lz(0), l(0), r(0) {} }; vector<node>seg; int create(){ seg.push_back(node()); return seg.size() - 1; } void push(int v, lint l, lint r){ } void update(int v, lint l, lint r, lint a, lint b, lint val){ if(b < l || r < a) return; push(v, l, r); if(a <= l && r <= b){ seg[v].sum += val; push(v, l, r); return; } lint m = (l + r) >> 1; if(!seg[v].l){ int aux = create(); seg[v].l = aux; } if(!seg[v].r){ int aux = create(); seg[v].r = aux; } update(seg[v].l, l, m, a, b, val); update(seg[v].r, m+1, r, a, b, val); push(seg[v].l, l, m); push(seg[v].r, m+1, r); seg[v].sum = seg[seg[v].l].sum + seg[seg[v].r].sum; } lint query(int v, lint l, lint r, lint a, lint b){ if(b < l || r < a) return 0; if(v == 0) return 0; push(v, l, r); if(a <= l && r <= b){ return seg[v].sum; } lint m = (l + r) >> 1; return query(seg[v].l, l, m, a, b) + query(seg[v].r, m+1, r, a, b); } bool check(){ lint cur = 0, sum = seg[1].sum; while(cur < sum){ lint cnt = query(1, 1, LIM, 1, cur); if(cnt < cur) return 0; cur = cnt + 1; } return 1; } bool init(int coinsCount, lint maxCoinSize, lint coins[]) { create(); create(); for(int i=0;i<coinsCount;i++){ update(1, 1, LIM, coins[i], coins[i], coins[i]); } return check(); } bool is_happy(int event, int coinsCount, lint coins[]) { for(int i=0;i<coinsCount;i++){ update(1, 1, LIM, coins[i], coins[i], coins[i] * event); } return check(); }

Compilation message (stderr)

happiness.cpp:10:1: error: 'vector' does not name a type
   10 | vector<node>seg;
      | ^~~~~~
happiness.cpp: In function 'int create()':
happiness.cpp:13:2: error: 'seg' was not declared in this scope
   13 |  seg.push_back(node());
      |  ^~~
happiness.cpp: In function 'void update(int, lint, lint, lint, lint, lint)':
happiness.cpp:24:3: error: 'seg' was not declared in this scope
   24 |   seg[v].sum += val;
      |   ^~~
happiness.cpp:29:6: error: 'seg' was not declared in this scope
   29 |  if(!seg[v].l){
      |      ^~~
happiness.cpp:33:6: error: 'seg' was not declared in this scope
   33 |  if(!seg[v].r){
      |      ^~~
happiness.cpp:37:9: error: 'seg' was not declared in this scope
   37 |  update(seg[v].l, l, m, a, b, val);
      |         ^~~
happiness.cpp: In function 'lint query(int, lint, lint, lint, lint)':
happiness.cpp:49:10: error: 'seg' was not declared in this scope
   49 |   return seg[v].sum;
      |          ^~~
happiness.cpp:52:15: error: 'seg' was not declared in this scope
   52 |  return query(seg[v].l, l, m, a, b) + query(seg[v].r, m+1, r, a, b);
      |               ^~~
happiness.cpp: In function 'bool check()':
happiness.cpp:56:22: error: 'seg' was not declared in this scope
   56 |  lint cur = 0, sum = seg[1].sum;
      |                      ^~~
grader.cpp: In function 'int main()':
grader.cpp:16:12: warning: unused variable 'max_code' [-Wunused-variable]
   16 |  long long max_code;
      |            ^~~~~~~~