제출 #654831

#제출 시각아이디문제언어결과실행 시간메모리
654831sandry24Detecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; #define pb push_back #define mp make_pair #define f first #define s second vi find_subset(ll l, ll u, vi w){ vector<pi> a; for(int i = 0; i < w.size(); i++) a.pb(mp(w[i], i)); sort(a.begin(), a.end()); ll sum = 0, left = -1, right = -1; for(int i = 0; i < w.size(); i++){ if(sum + a[i].f <= u){ sum += a[i].f; right = i; left = 0; } else break; } if(l == -1) return {}; while(sum < l && right != w.size()-1){ sum -= a[left].f; sum += a[right+1].f; right++; left++; } if(sum < l) return {}; vi ans; for(int i = left; i <= right; i++) ans.pb(a[i].s); return ans; }

컴파일 시 표준 에러 (stderr) 메시지

molecules.cpp: In function 'vi find_subset(ll, ll, vi)':
molecules.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i = 0; i < w.size(); i++)
      |                    ~~^~~~~~~~~~
molecules.cpp:18:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i = 0; i < w.size(); i++){
      |                    ~~^~~~~~~~~~
molecules.cpp:27:28: 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]
   27 |     while(sum < l && right != w.size()-1){
      |                      ~~~~~~^~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccpMIg8b.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