Submission #1309915

#TimeUsernameProblemLanguageResultExecution timeMemory
1309915michael12Distributing Candies (IOI21_candies)C++20
Compilation error
0 ms0 KiB
#include "candies.h" #include<bits/stdc++.h> #define ff first #define ss second #define pb push_back #define mp make_pair using namespace std; const int maxn = 200005; struct segtree { vector<int> tree, lazy; int n; segtree(int n) : n(n) { tree.assign(4 * n, 0); lazy.assign(4 * n, 0); } // void build(int node, int start, int end, const vector<int> &a) { // if (start == end) { // tree[node] = a[start]; // return; // } // int mid = (start + end) / 2; // build(2 * node, start, mid, a); // build(2 * node + 1, mid + 1, end, a); // tree[node] = min(tree[2 * node], tree[2 * node + 1]); // } void push(int node, int start, int end, vector<int>& c) { if(lazy[node] != 0){ if(start == end){ if(lazy[node] > 0){ tree[node] = min(c[start], tree[node] + lazy[node]); } else{ tree[node] = max(0, tree[node] + lazy[node]); } } else { lazy[2 * node] += lazy[node]; lazy[2 *node + 1] += lazy[node]; } lazy[node] = 0; } } void update(int node, int start, int end, int l, int r, int val, vector<int>& c) { push(node, start, end, c); if (start > r || end < l) return; if (l <= start && end <= r) { lazy[node] += val; push(node, start, end, c); return; } int mid = (start + end) / 2; update(2 * node, start, mid, l, r, val, c); update(2 * node + 1, mid + 1, end, l, r, val, c); } int get(int node, int start, int end, int id, vector<int>& c){ push(node, start, end, c); if(start == end){ return tree[node]; } else{ int mid = (start + end) / 2; if(mid >= id){ return get(2 * node, start, mid, id, c); } else{ return get(2 * node + 1, mid + 1, end, id, c); } } } }; vector<int> distribute_candies(vector<int>& c, vector<int>& l, vector<int>& r, vector<int>& v){ int sz = c.size(); segtree ST(sz); for(int dy = 0; dy < v.size(); dy++){ ST.update(1, 0, sz - 1, l[dy], r[dy], v[dy], c); } vector<int> ans(sz); for(int i = 0; i < sz; i++){ ans[i] = ST.get(1, 0, sz - 1, i, c); } return ans; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccFtMTH2.o: in function `main':
grader.cpp:(.text.startup+0x2fe): 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