Submission #416664

#TimeUsernameProblemLanguageResultExecution timeMemory
416664schseDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> #define int long long //#include "molecules grader.cpp" using namespace std; signed find_subset(signed l, signed u, signed *w, signed n, signed *result) { vector<pair<int, int>> arr; vector<int> prefarr(n + 1); 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[i - a] = arr[i].second; return b - a; } } return 0; }

Compilation message (stderr)

molecules.cpp: In function 'int find_subset(int, int, int*, int, int*)':
molecules.cpp:24: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]
   24 |         while (l > prefarr[b] - prefarr[a]&&b!=arr.size())
      |                                             ~^~~~~~~~~~~~
molecules.cpp:19:22: warning: unused variable 'tmp' [-Wunused-variable]
   19 |     int a = 0, b = 0,tmp;
      |                      ^~~
/usr/bin/ld: /tmp/ccnDWnvU.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