Submission #900086

#TimeUsernameProblemLanguageResultExecution timeMemory
900086mannshah1211Detecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; #define int long long #define f first #define s second #define pb push_back #define all(x) x.begin(), x.end() vector<int> find_subset(int l, int u, vector<int> w) { if (accumulate(all(w), 0LL) < l) { return {}; } vector<pair<int, int>> indices; for (int i = 0; i < w.size(); i++) { indices.pb({w[i], i}); } if (indices[0].f > u) { return {}; } sort(all(indices)); int cursum = 0, longest = 0; for (int i = 0; i < indices.size(); i++) { cursum += indices[i].f; if (cursum >= l) { cursum -= indices[i].f, longest = i; break; } } for (int i = longest; i < indices.size(); i++) { cursum += indices[i].f; cursum -= indices[i - longest].f; if (cursum >= l && cursum <= u) { vector<int> answer; for (int j = i; j >= i - longest + 1; j--) { answer.pb(indices[j].s); } return answer; } } return {}; }

Compilation message (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:15:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (int i = 0; i < w.size(); i++) {
      |                     ~~^~~~~~~~~~
molecules.cpp:23: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]
   23 |     for (int i = 0; i < indices.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~~
molecules.cpp:30:29: 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]
   30 |     for (int i = longest; i < indices.size(); i++) {
      |                           ~~^~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc22iJWM.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