이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
#define ll long long
const int mxN = 2e5;
map<pair<ll, int>, bool> mp;
vector<int> solve(ll pts, int pos, bitset<200000>& bs, int l, int u, vector<int>& w){
vector<int> ans;
int n = w.size();
if(pos == n){
if(pts >= l && pts <= u){
for(int i = 0; i<bs.size(); ++i){
if(bs[i]){
ans.push_back(i);
}
}
}
return ans;
}
if(pts > u || mp[{pts, pos}] || pos > n){
return ans;
}
mp[{pts, pos}] = 1;
if(pts >= l && pts <= u){
vector<int> ans;
for(int i = 0; i<bs.size(); ++i){
if(bs[i]){
ans.push_back(i);
}
}
return ans;
}
bs[pos] = 1;
vector<int> intento1 = solve(pts+w[pos], pos+1, bs, l, u, w);
if(intento1.size()){
return intento1;
}else{
bs[pos] = 0;
vector<int> intento2 = solve(pts, pos+1, bs, l, u, w);
if(intento2.size()){
return intento2;
}else{
return ans;
}
}
return ans;
}
vector<int> find_subset(int l, int u, vector<int> w){
bitset<200000> bt;
vector<int> ans = solve(0, 0, bt, l, u, w);
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
molecules.cpp: In function 'std::vector<int> solve(long long int, int, std::bitset<200000>&, int, int, std::vector<int>&)':
molecules.cpp:16:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::size_t' {aka 'long unsigned int'} [-Wsign-compare]
16 | for(int i = 0; i<bs.size(); ++i){
| ~^~~~~~~~~~
molecules.cpp:30:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::size_t' {aka 'long unsigned int'} [-Wsign-compare]
30 | for(int i = 0; i<bs.size(); ++i){
| ~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |