제출 #101300

#제출 시각아이디문제언어결과실행 시간메모리
101300chunghanDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> //#include"molecules.h" using namespace std; typedef long long int lld; typedef pair<int, int> pii; vector<int> find_subset(int l, int u, vector<int> w) { vector<pii> p; vector<int> rst; int a = 0, b = 0, sum = 0; for (int i = 0; i < (int)w.size(); i++) p.push_back(pii(w[i], i)); sort(p.begin(), p.end()); while (1) { if (sum > u) sum -= p[a++].first; else if (b == w.size()) break; else if (sum < l) sum += p[b++].first; else break; } //cout << sum << endl; if (b < w.size()) for (int i = a; i < b; i++) rst.push_back(p[i].second); return rst; } int main() { vector<int> w; w.push_back(15); w.push_back(16); w.push_back(17); w.push_back(18); vector<int> r = find_subset(10, 20, w); for (int i = 0; i < r.size(); i++) cout << r[i] << ' '; return 0; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:18:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         else if (b == w.size()) break;
                  ~~^~~~~~~~~~~
molecules.cpp:23:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (b < w.size())
         ~~^~~~~~~~~~
molecules.cpp: In function 'int main()':
molecules.cpp:36:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < r.size(); i++) cout << r[i] << ' ';
                     ~~^~~~~~~~~~
/tmp/ccAD3wsh.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccjlx6uz.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status