제출 #853214

#제출 시각아이디문제언어결과실행 시간메모리
853214hngwlogDetecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; #define fi first #define se second #define _size(x) (int)x.size() #define BIT(i, x) ((x >> i) & 1) #define MASK(n) ((1 << n) - 1) #define REP(i, n) for (int i = 0, _n = (n); i < _n; i++) #define FOR(i, a, b) for (int i = a, _b = (b); i <= _b; i++) #define FORD(i, a, b) for (int i = a, _b = (b); i >= _b; i--) #define FORB1(i, mask) for (int i = mask; i > 0; i ^= i & - i) #define FORB0(i, n, mask) for (int i = ((1 << n) - 1) ^ mask; i > 0; i ^= i & - i) #define FORALL(i, a) for (auto i: a) #define fastio ios_base::sync_with_stdio(0); cin.tie(0); vector<int> find_subset(long long l, long long u, vector<long long> w) { vector<pair<long long, int>> g; int n = _size(w); REP(i, n) g.push_back({w[i], i}); sort(g.begin(), g.end()); priority_queue<pair<long long, int>> inPQ, notinPQ; long long res = 0; REP(i, n) { if (res + g[i].fi <= u) { res += g[i].fi; inPQ.push({- g[i].fi, g[i].se}); } else notinPQ.push(g[i]); } if (res < l && notinPQ.empty()) return {}; if (inPQ.empty()) return {}; while (res < l) { pair<long long, int> subtract = inPQ.top(); inPQ.pop(); pair<long long, int> add = notinPQ.top(); notinPQ.pop(); if (add.fi + subtract.fi <= 0) { inPQ.push({- add.fi, add.se}); notinPQ.push({- subtract.fi, subtract.se}); break; } res += (add.fi + subtract.fi); inPQ.push({- add.fi, add.se}); notinPQ.push({- subtract.fi, subtract.se}); } vector<pair<long long, int>> _g; while (!notinPQ.empty()) { _g.push_back(notinPQ.top()); notinPQ.pop(); } vector<int> ans; while (!inPQ.empty()) { ans.push_back(inPQ.top().se); inPQ.pop(); } if (res < l) { if (_size(_g) && res + _g.back().fi >= l && res + _g.back().fi <= u) ans.push_back(_g.back().se); else return {}; } sort(ans.begin(), ans.end()); return ans; }

컴파일 시 표준 에러 (stderr) 메시지

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