Submission #737282

#TimeUsernameProblemLanguageResultExecution timeMemory
737282AmaarsaaDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; using ll = long long; vector<int> find_subset(ll l, ll u, vector<int> w) { ll p, sum, s, j, r, i; sort (w.begin(), w.end()); s = 0; r = w.size(); ll a[r + 2]; a[0] = w[0]; for ( i = 1; i < w.size(); i ++) { a[i] = a[i - 1] + w[i]; } vector < int > Ans; Ans.clear(); for (i = 0; i < w.size(); i ++) { p = upper_bound(w.begin(), w.end(), w[i] + (u - l)) - w.begin(); p --; sum = a[p] - a[i] + w[i]; while (sum > u && p > i) { sum -= w[p]; p --; } if (sum >= l && sum <= u) { for ( j = i; j <= p; j ++) { Ans.push_back(w[j]); } break; } } return Ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(ll, ll, std::vector<int>)':
molecules.cpp:14:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for ( i = 1; i < w.size(); i ++) {
      |               ~~^~~~~~~~~~
molecules.cpp:19:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |  for (i = 0; i < w.size(); i ++) {
      |              ~~^~~~~~~~~~
molecules.cpp:7:13: warning: variable 's' set but not used [-Wunused-but-set-variable]
    7 |  ll p, sum, s, j, r, i;
      |             ^
/usr/bin/ld: /tmp/ccl41anV.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