Submission #581882

#TimeUsernameProblemLanguageResultExecution timeMemory
581882adrilenDistributing Candies (IOI21_candies)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; typedef pair<int, int> pii; const int maxn = 2e5; const ll maxc = 1e9; const int siz = (1 << 18); ll segment_tree[siz * 2 + 1] = { 0 }; void update(int pos, pii wan, pii sear, int val) { if (wan.first > sear.second || sear.first > wan.second) return ; if (wan.first <= sear.first && sear.second <= wan.second) { segment_tree[pos] += val; return ; } int mid = (sear.first + sear.second) / 2; update(pos * 2, wan, pii(sear.first, mid), val); update(pos * 2 + 1, wan, pii(mid + 1, sear.second), val); } void calc(vector <int> &out, int pos, vector <ll> &maxval, ll val) { if (pos >= siz) { out[pos - siz] = min(maxval[pos - siz], val + segment_tree[pos]); } else { val = min(maxc, val + segment_tree[pos]); calc(out, pos * 2, maxval, val); calc(out, pos * 2 + 1, maxval, val); } } vector <int> positive(vector <ll> &c, vector<int> &l, vector<int> &r, vector<int> &v) { int n = c.size(), q = v.size(); for (int i = 0; i < q; i++) { update(1, pii(l[i], r[i]), pii(0, siz - 1), v[i]); } vector <int> out(siz); calc(out, 1, c, 0); out.resize(n); return out; } vector<int> distribute_candies(vector <ll> c, vector<int> l, vector<int> r, vector<int> v) { vector <int> s = positive(c, l, r, v); return s; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccTyA4Fg.o: in function `main':
grader.cpp:(.text.startup+0x30e): undefined reference to `distribute_candies(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status