Submission #685698

#TimeUsernameProblemLanguageResultExecution timeMemory
685698BliznetcDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "molecules.h" //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC target("avx2") using namespace std; #define pb push_back #define sz size() #define all(x) x.begin(), x.end() #define F first #define S second #define int long long typedef pair < int, int > pii; typedef vector < int > vi; typedef vector < vi > vvi; vi find_subset(int l, int u, vi w) { int n = w.sz; pii a[n + 7]; int sum = 0; for (int i = 1; i <= n; i++) { a[i] = {w[i - 1], i}; sum += a[i].F; } sort (a + 1, a + n + 1); if (sum < l) { return {}; } int r = u; if (a[1].F > u) { return {}; } int cur = 0; vi result; for (int i = 1; i <= n; i++) { if (cur + a[i].F >= l) { if (cur + a[i].F <= r) { cur += a[i].F; result.pb(a[i].S); } break; } cur += a[i].F; result.pb(a[i].S); } if (cur < l) { for (int i = 0; i < result.size(); i++) { if (cur - a[i + 1].F + a[n].F <= r) { result[i] = a[n].S; break; } } } if (cur >= l && cur <= r) { return result; } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'vi find_subset(long long int, long long int, vi)':
molecules.cpp:55:27: 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]
   55 |         for (int i = 0; i < result.size(); i++) {
      |                         ~~^~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccSuvGJ2.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