Submission #736866

#TimeUsernameProblemLanguageResultExecution timeMemory
736866MODDIHappiness (Balkan15_HAPPINESS)C++14
Compilation error
0 ms0 KiB
#include "happiness.h" //#include "grader.cpp" #include <bits/stdc++.h> using namespace std; long long mx; struct Node{ long long sum; int l, r; Node() : sum(0), l(-1), r(-1){} }; Node tree[40*201000]; int cnt = 2; void update(int node, long long pos, long long add, long long l, long long r){ if(l == r && l == pos){ tree[node].sum += add; } else{ long long mid = (l+ r) / 2; if(tree[node].l == -1){ tree[node].l = cnt++; } if(tree[node].r == -1){ tree[node].r = cnt++; } if(pos <= mid){ update(tree[node].l, pos, add, l, mid); } else update(tree[node].r, pos, add, mid+1, r); tree[node].sum = tree[tree[node].l].sum + tree[tree[node].r].sum; } } long long query(int node, long long L, long long R, long long l, long long r){ if(r < L || l > R) return 0; if(L <= l && r <= R) return tree[node].sum; long long mid = (l + r) / 2; if(tree[node].l == -1){ tree[node].l = cnt++; } if(tree[node].r == -1) tree[node].r = cnt++; if(L > mid) return query(tree[node].r, L, R, mid+1, r); else if(R <= mid) return query(tree[node].l, L, R, l, mid; else{ return query(tree[node].l, l, mid) + query(tree[node].r, mid+1, r); } } bool check(){ long long coin = 1, tot = query(1, 1, mx, 1, 1e12); while(coin <= mx){ long long sum = query(1, 1, coin,1,1e12); if(sum + 1 > mx) return true; if(tot == sum) return true; if(query(1, coin+1, sum+1,1,1e12) == 0) return false; coin = sum + 1; } return true; } bool init(int n, long long M, long long a[]){ ios_base::sync_with_stdio(false); cin.tie(0); mx = M; tree[1].sum = 0; for(int i = 0; i < n; i++) update(1, a[i], a[i], 1, 1e12); return check(); } bool is_happy(int e, int n, long long a[]){ for(int i = 0; i < n; i++) update(1, a[i], a[i]*e, 1, 1e12); return check(); }

Compilation message (stderr)

happiness.cpp: In function 'long long int query(int, long long int, long long int, long long int, long long int)':
happiness.cpp:46:59: error: expected ')' before ';' token
   46 |  else if(R <= mid) return query(tree[node].l, L, R, l, mid;
      |                                ~                          ^
      |                                                           )
happiness.cpp:48:36: error: too few arguments to function 'long long int query(int, long long int, long long int, long long int, long long int)'
   48 |   return query(tree[node].l, l, mid) + query(tree[node].r, mid+1, r);
      |                                    ^
happiness.cpp:34:11: note: declared here
   34 | long long query(int node, long long L, long long R, long long l, long long r){
      |           ^~~~~
happiness.cpp:48:68: error: too few arguments to function 'long long int query(int, long long int, long long int, long long int, long long int)'
   48 |   return query(tree[node].l, l, mid) + query(tree[node].r, mid+1, r);
      |                                                                    ^
happiness.cpp:34:11: note: declared here
   34 | long long query(int node, long long L, long long R, long long l, long long r){
      |           ^~~~~
grader.cpp: In function 'int main()':
grader.cpp:16:12: warning: unused variable 'max_code' [-Wunused-variable]
   16 |  long long max_code;
      |            ^~~~~~~~