#include <bits/stdc++.h>
#define taskname "test"
#define fi first
#define se second
#define pb push_back
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
using ll = long long;
using pii = pair <ll, ll>;
using pil = pair <ll, ll>;
using pli = pair <ll, ll>;
using pll = pair <ll, ll>;
using ull = unsigned ll;
mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count());
ll min(const ll &a, const ll &b){
return (a < b) ? a : b;
}
ll max(const ll &a, const ll &b){
return (a > b) ? a : b;
}
//const ll Mod = 1000000009;
//const ll Mod2 = 999999999989;
//only use when required
const ll maxN = 1e5 + 1;
const ll inf = 1e12;
ll n;
ll a[maxN];
ll node_cnt = 1;
struct TNode{
TNode *lp, *rp;
ll val;
TNode() : lp(nullptr), rp(nullptr), val(0){}
void update(TNode* id, ll i, ll v, ll l = 1, ll r = inf){
if (i < l || i > r) return;
id->val += v;
if (l == r){
return;
}
id->create_node();
ll mid = (l + r) / 2;
update(id->lp, i, v, l, mid);
update(id->rp, i, v, mid + 1, r);
}
void create_node(){
if (!lp) lp = new TNode();
if (!rp) rp = new TNode();
}
ll get(TNode* id, ll i, ll j, ll l = 1, ll r = inf){
if (r < i || l > j) return 0;
if (i <= l && r <= j) return id->val;
ll mid = (l + r) / 2;
ll ret = 0;
if (id->lp) ret += get(id->lp, i, j, l, mid);
if (id->rp) ret += get(id->rp, i, j, mid + 1, r);
return ret;
}
};
TNode* st;
bool check(){
ll tem = 1, last = st->val;
while (tem < last){
ll t = st->get(st, 1, tem);
if (t < tem) return 0;
tem = t + 1;
}
return 1;
}
bool init(ll N, ll M, ll a[]){
n = N;
st = new TNode();
for (ll i = 0; i < n; ++i) st->update(st, a[i], a[i]);
return check();
}
bool is_happy(ll t, ll K, ll a[]){
for (ll i = 0; i < K; ++i) st->update(st, a[i], a[i] * t);
return check();
}
Compilation message
grader.cpp: In function 'int main()':
grader.cpp:16:12: warning: unused variable 'max_code' [-Wunused-variable]
16 | long long max_code;
| ^~~~~~~~
/usr/bin/ld: /tmp/cczEvrl3.o: in function `main':
grader.cpp:(.text.startup+0x96): undefined reference to `init(int, long long, long long*)'
/usr/bin/ld: grader.cpp:(.text.startup+0x160): undefined reference to `is_happy(int, int, long long*)'
collect2: error: ld returned 1 exit status