# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
35048 | model_code | Bootfall (IZhO17_bootfall) | C++11 | 1000 ms | 2528 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#define ll long long
#define pb push_back
#define f first
#define s second
#define mp make_pair
using namespace std;
const int maxn = 5e2 + 11;
int n, a[maxn], s;
bool dp[2 * maxn * maxn];
int main() {
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> a[i];
s += a[i];
}
if (s % 2 != 0) {
cout << 0;
return 0;
}
dp[0] = 1;
s /= 2;
for (int i = 0; i < n; ++i)
for (int sum = s; sum >= 0; --sum)
if (dp[sum] && sum + a[i] <= s)
dp[sum + a[i]] = 1;
if (!dp[s]) {
cout << 0;
return 0;
}
vector < int > ans;
for (int x = 0; x <= s + s; x++) {
bool ok = 1;
for (int i = 0; i < n; ++i) {
int curs = s + s - a[i] + x;
if (curs % 2 != 0) {
ok = 0;
break;
}
curs /= 2;
memset(dp, 0, sizeof(dp));
dp[0] = 1;
swap(a[i], x);
for (int j = 0; j < n; ++j)
for (int sum = curs; sum >= 0; --sum)
if (dp[sum] && sum + a[j] <= curs)
dp[sum + a[j]] = 1;
swap(a[i], x);
if (!dp[curs]) {
ok = 0;
break;
}
}
if (ok)
ans.pb(x);
}
cout << ans.size() << endl;
for (int i = 0; i < ans.size(); ++i)
cout << ans[i] << ' ';
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... |