제출 #416674

#제출 시각아이디문제언어결과실행 시간메모리
416674schseDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> #define int long long //#include "molecules grader.cpp" using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { signed n= w.size(); vector<pair<int, int>> arr; vector<int> prefarr(n + 1),result; for (int i = 0; i < n; i++) { arr.push_back({w[i], i}); } sort(arr.begin(), arr.end()); prefarr[0] = 0; for (int i = 0; i < n; i++) prefarr[i + 1] = prefarr[i] + arr[i].first; int a = 0, b = 0,tmp; bool change=true; while (change) { change=false; while (l > prefarr[b] - prefarr[a]&&b!=arr.size()) b++, change=true; while (u < prefarr[b] - prefarr[a]&&a<b) a++, change=true; if (l <= prefarr[b] - prefarr[a] && prefarr[b] - prefarr[a] <= u) { for (int i = a; i < b; i++) result.push_back(arr[i].second); return result; } } 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:25:46: 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]
   25 |         while (l > prefarr[b] - prefarr[a]&&b!=arr.size())
      |                                             ~^~~~~~~~~~~~
molecules.cpp:20:22: warning: unused variable 'tmp' [-Wunused-variable]
   20 |     int a = 0, b = 0,tmp;
      |                      ^~~
/usr/bin/ld: /tmp/ccuuQUfp.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