제출 #101279

#제출 시각아이디문제언어결과실행 시간메모리
101279chunghanDetecting 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> solve(int l, int u, vector<int> w) { vector<pii> p; vector<int> rst; vector<lld> S; int r1, r2; for (int i = 0; i < (int)w.size(); i++) p.push_back(pii(w[i], i)); sort(p.begin(), p.end()); S.push_back(p[0].first); for (int i = 1; i < (int)p.size(); i++) S.push_back(S[i-1] + p[i].first); for (int i = 1; i < (int)p.size(); i++) { lld t = S[i] - u; int j = lower_bound(S.begin(), S.end(), t) - S.begin() + 1; j--; if (S[i] - S[j] >= l) { r1 = j; r2 = i; break; } } for (int i = r1; i <= r2; i++) rst.push_back(p[i].second); return rst; }

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

molecules.cpp: In function 'std::vector<int> solve(int, int, std::vector<int>)':
molecules.cpp:30:24: warning: 'r2' may be used uninitialized in this function [-Wmaybe-uninitialized]
     for (int i = r1; i <= r2; i++)
                      ~~^~~~~
molecules.cpp:13:9: warning: 'r1' may be used uninitialized in this function [-Wmaybe-uninitialized]
     int r1, r2;
         ^~
/tmp/ccrcKysN.o: In function `main':
grader.cpp:(.text.startup+0x152): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status