제출 #685695

#제출 시각아이디문제언어결과실행 시간메모리
685695BliznetcDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.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; int ptr = 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.sz; i++) { if (cur - a[i].F + a[n].F <= r) { result[i] = a[n].S; break; } } } if (cur >= l && cur <= r) { return result; } return {}; } /* void solve(){ } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; int l = 15, u = 17; int a[4] = {6, 8, 8, 7}; int result[10]; int pos = find_subset(l, u, a, 4, result); cout << pos; // cin >> t; // while (t--) { // solve(); // cout << "\n"; // } } */

컴파일 시 표준 에러 (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.sz; i++) {
      |                           ^
molecules.cpp:40:9: warning: unused variable 'ptr' [-Wunused-variable]
   40 |     int ptr = 0;
      |         ^~~
/usr/bin/ld: /tmp/ccNTPMUB.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