제출 #138284

#제출 시각아이디문제언어결과실행 시간메모리
138284arthurconmyDetecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #ifndef ARTHUR_LOCAL #include "molecules.h" #endif using namespace std; vector<int> find_subset(int l, int u, vector<int> W) { vector<int> use; int cur = 0; for(int i=0; i<W.size(); i++) { int w = W[i]; if(w>=l && w<=u) { return {w}; } if(w<l) { use.push_back(i); cur += w; if(cur > u) break; } } while(cur>u) { if(use.empty()) return {}; cur -= W[use.back()]; use.pop_back(); } if(use.empty() || !(cur>=l) || !(cur<=r)) return {}; else return use; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<W.size(); i++)
                  ~^~~~~~~~~
molecules.cpp:37:43: error: 'r' was not declared in this scope
     if(use.empty() || !(cur>=l) || !(cur<=r)) return {};
                                           ^
molecules.cpp:39:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^