# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
481227 | glome | Detecting Molecules (IOI16_molecules) | C++17 | 164 ms | 1624 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> ans;
vector<vector<int>> need(1e4 + 1);
struct S {
int b = 0;
vector<int> ind;
};
vector<S> ok(1e4 + 1);
void dfs(int a) {
if(a == 0) {
return;
}
for (int i = 0; i<ok[a].ind.size(); i++) {
ans.push_back(ok[a].ind[i]);
}
for (int u : need[a]) {
dfs(u);
}
}
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
ok[0].b = 1;
int cnt = 0;
for (int i : w) {
for (int j = u; j>=i; j--) {
if(ok[j-i].b && !ok[j].b) {
need[j].push_back(j-i);
ok[j].b = 1;
(ok[j].ind).push_back(cnt);
}
}
cnt++;
}
for (int i = l; i<=u; i++) {
if(ok[i].b) {
dfs(i);
return ans;
}
}
return ans;
}
Compilation message (stderr)
# | 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... |