# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
747762 | adrilen | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;
#include "molecules.h"
constexpr int maxu = 5e5 + 5;
int last[maxu] = { 0 };
bool found[maxu] = { 0 };
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
found[0] = true;
int highest = 0;
int p;
for (int v = 0; v < (int)w.size(); v++)
{
for (int i = min(highest, u - w[v]); i >= 0; i--)
{
if (!found[i]) continue;
// cout << i << endl;
if (i + w[v] >= maxu) continue;
if (found[i + w[v]]) continue;
found[i + w[v]] = true;
last[i + w[v]] = v;
if (l <= i + w[v] && i + w[v] <= u) {
p = i + w[v];
goto finish;
}
}
highest += w[v];
}
return vector<int>{};
finish:
vector <int> output;
// int i = 15;
while (p != 0)
{
output.emplace_back(last[p]);
// cout << "p" << p << endl;
p -= w[last[p]];
}
return output;
}#include<bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;
#include "molecules.h"
constexpr int maxu = 5e5 + 5;
int last[maxu] = { 0 };
bool found[maxu] = { 0 };
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
found[0] = true;
int highest = 0;
int p;
for (int v = 0; v < (int)w.size(); v++)
{
for (int i = min(highest, u - w[v]); i >= 0; i--)
{
if (!found[i]) continue;
// cout << i << endl;
if (i + w[v] >= maxu) continue;
if (found[i + w[v]]) continue;
found[i + w[v]] = true;
last[i + w[v]] = v;
if (l <= i + w[v] && i + w[v] <= u) {
p = i + w[v];
goto finish;
}
}
highest += w[v];
}
return vector<int>{};
finish:
vector <int> output;
// int i = 15;
while (p != 0)
{
output.emplace_back(last[p]);
// cout << "p" << p << endl;
p -= w[last[p]];
}
return output;
}