제출 #999329

#제출 시각아이디문제언어결과실행 시간메모리
999329vuhDetecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; #define inf INT_MAX std::vector<int> find_subset(int l, int u, std::vector<int> w){ int n = w.size(),mini = inf,maxi = -inf,x = u - l,sum = 0; for(int i =0;i<n ;i++){ mini = min(mini,w[i]); maxi = max(maxi,w[i]); sum += w[i]; } vector <int> ans; if(maxi - mini > x){ return vector <int> (0); } while(!next_permutation(w.begin(),w.end())){ for(int i =0;i<n ;i++){ sum = 0; for(int j =0;j<=i ;j++){ sum += w[i]; } if((sum >= l && sum <= u) || (sum <= l && sum >= u)){ for(int j =0;j<=i ;j++){ ans.push_back(a[i]); } return ans; } } } }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:25:35: error: 'a' was not declared in this scope
   25 |                     ans.push_back(a[i]);
      |                                   ^
molecules.cpp:13:18: warning: control reaches end of non-void function [-Wreturn-type]
   13 |     vector <int> ans;
      |                  ^~~