# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
173511 | AllMight | Bootfall (IZhO17_bootfall) | C++14 | 1077 ms | 736 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
using namespace std;
const int N = 502;
int n;
int a[N];
int cnt[N * N];
vector <int> v;
void check(int ind)
{
vector <bool> knp(N * N, false);
knp[0] = true;
priority_queue <int> pq[2];
pq[0].push(0);
for (int i = 0, f = 0; i < n; i++, f = 1 - f) {
if (i == ind) {
f = 1 - f;
continue;
}
while (!pq[f].empty()) {
int tp = pq[f].top();
pq[f].pop();
pq[1 - f].push(tp);
if (!knp[tp + a[i]])
pq[1 - f].push(tp + a[i]);
knp[tp + a[i]] = true;
}
}
int sum;
if (pq[0].empty())
sum = pq[1].top();
else
sum = pq[0].top();
for (int i = 0; 2 * i < sum; i++) {
if (!knp[i]) continue;
int ans = sum - 2 * i;
cnt[ans]++;
if (ind == 0)
v.push_back(ans);
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin >> n;
vector <bool> knp(N * N, false);
knp[0] = true;
priority_queue <int> pq[2];
pq[0].push(0);
for (int i = 0, f = 0; i < n; i++, f = 1 - f) {
cin >> a[i];
while (!pq[f].empty()) {
int tp = pq[f].top();
pq[f].pop();
pq[1 - f].push(tp);
if (!knp[tp + a[i]])
pq[1 - f].push(tp + a[i]);
knp[tp + a[i]] = true;
}
}
int sum;
if (pq[0].empty())
sum = pq[1].top();
else
sum = pq[0].top();
if (sum % 2 || !knp[sum / 2]) {
cout << "0\n";
return 0;
}
for (int i = 0; i < n; i++)
check(i);
vector <int> ans;
for (int i = 0; i < v.size(); i++)
if (cnt[v[i]] == n)
ans.push_back(v[i]);
sort(ans.begin(), ans.end());
cout << ans.size() << endl;
for (int i = 0; i < ans.size(); i++)
cout << ans[i] << ' ';
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... |