# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1008857 | Ausp3x | Detecting Molecules (IOI16_molecules) | C++17 | 1035 ms | 2392 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// 人外有人,天外有天
// author: Ausp3x
#pragma GCC optimize("O1, O2, O3, Ofast, unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long lng;
typedef unsigned int uint;
typedef unsigned long long ulng;
using namespace std;
using namespace __gnu_pbds;
int const INF32 = 0x3f3f3f3f;
lng const INF64 = 0x3f3f3f3f3f3f3f3f;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<int> dp(u + 1, -1);
for (int i = 0; i < n; i++)
for (int j = u; j >= 0; j--) {
if (j - w[i] < 0)
continue;
if (j - w[i] == 0) {
if (dp[j] == -1)
dp[j] = i;
continue;
}
if (dp[j] != -1 || dp[j - w[i]] == -1)
continue;
dp[j] = i;
}
// for (int i = 0; i <= u; i++)
// cout << dp[i] << ' ';
// cout << endl;
vector<int> ans;
for (int i = l; i <= u; i++) {
if (dp[i] == -1)
continue;
int ii = i;
while (ii > 0) {
ans.push_back(dp[ii]);
ii -= w[dp[ii]];
}
break;
}
return ans;
}
/*
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
cin >> t;
while (t--) {
int l, u, n;
cin >> l >> u >> n;
vector<int> w(n);
for (int &x : w)
cin >> x;
vector<int> ans = find_subset(l, u, w);
cout << ans.size() << endl;
for (int x : ans)
cout << x << ' ';
cout << endl;
}
return 0;
}
//*/
컴파일 시 표준 에러 (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... |