이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#ifdef dremix
#define p(x) cerr<<#x<<" = "<<x<<endl;
#define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl;
#define pp(x) cerr<<#x<<" = ("<<x.F<<" - "<<x.S<<")"<<endl;
#define pv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u<<", ";cerr<<"}"<<endl;
#define ppv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u.F<<"-"<<u.S<<", ";cerr<<"}"<<endl;
#else
#define p(x) {}
#define p2(x,y) {}
#define pp(x) {}
#define pv(x) {}
#define ppv(x) {}
#endif
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const int N = 5e5+5;
const int MOD = 1e9+7;
const ll INF = 1e18+5;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n = w.size();
//sort(all(w));
set <int> arr;
vector<int> neo;
arr.insert(0);
int v[N];
memset(v,-1,sizeof(v));
//pv(v)
int i = 0;
int found = 0;
pv(w)
for(auto &x : w){
for(auto &y : arr){
if(v[x+y] == -1){
neo.push_back(x+y);
v[x+y] = i;
}
}
for(auto &y : neo){
arr.insert(y);
if(l<=y && y<=u){
found = y;
break;
}
}
if(found)break;
neo.clear();
i++;
}
vector<int> ans;
while(found){
ans.push_back(v[found]);
found -= w[v[found]];
}
pv(ans)
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:30:9: warning: unused variable 'n' [-Wunused-variable]
30 | int n = w.size();
| ^
# | 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... |