제출 #959420

#제출 시각아이디문제언어결과실행 시간메모리
959420Mystic03Detecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include <algorithm> using namespace std; #define int long long std::vector<int> find_subset(int l, int u, std::vector<int> w) { int p1 = 0; int r = 0; int n = w.size(); std::vector<pair<int, int>> ele; for (int i = 0; i < n; i++) { ele.push_back({ w[i], i }); } sort(ele.begin(), ele.end()); int currSum = 0; while (currSum < l) { if (r == ele.size()) return std::vector<int>(0); currSum += ele[r].first; r++; } vector<int> res; if (currSum <= u) { for (int i = 0; i < r; i++) { res.push_back(ele[i].second); } return res; } r--; currSum -= ele[r].first; for (int i = r; i < ele.size(); i++) { currSum += ele[i].first; currSum -= ele[p1++].first; if (currSum >= l && currSum <= u) { for (int j = p1; j <= i; j++) { res.push_back(ele[j].second); } return res; } } return std::vector<int>(0); }

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

molecules.cpp: In function 'std::vector<long long int> find_subset(long long int, long long int, std::vector<long long int>)':
molecules.cpp:21:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         if (r == ele.size())    return std::vector<int>(0);
      |             ~~^~~~~~~~~~~~~
molecules.cpp:36:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i = r; i < ele.size(); i++) {
      |                     ~~^~~~~~~~~~~~
/usr/bin/ld: /tmp/cc3ahq71.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