# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
92723 | toloraia | Bootfall (IZhO17_bootfall) | C++14 | 1089 ms | 1016 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC("O3")
using namespace std;
const int N = 505, M = 250005;
int n;
int a[N];
bool F[M];
int A[M], B[M];
int np, nn;
int S;
int ANS[M];
int ans[M];
int main()
{
cin>>n;
for (int i = 1; i <= n; i++){
cin>>a[i];
S += a[i];
}
sort (a + 1, a + n + 1);
bool ok = 0;
for (int i = 2; i <= n; i++)
if ((a[i] - a[i - 1]) % 2 == 1)
ok = 1;
if (S % 2 == 1)
ok = 1;
if (ok){
cout<<0<<endl;
return 0;
}
F[0] = 1;
np = 1;
A[1] = 0;
for (int i = 1; i <= n; i++){
nn = 0;
for (int j = 1; j <= np; j++)
if (F[A[j] + a[i]] == 0){
B[++nn] = A[j] + a[i];
F[B[nn]] = 1;
}
for (int j = 1; j <= nn; j++)
A[++np] = B[j];
}
if (F[S / 2] == 0){
cout<<0<<endl;
return 0;
}
//cout<<S<<endl;
for (int I = 1; I <= n; I++){
for (int i = 0; i <= S; i++)
F[i] = 0;
F[0] = 1;
np = 1;
A[1] = 0;
for (int i = 1; i <= n; i++){
if (i == I)
continue;
nn = 0;
for (int j = 1; j <= np; j++)
if (F[A[j] + a[i]] == 0){
B[++nn] = A[j] + a[i];
F[B[nn]] = 1;
}
for (int j = 1; j <= nn; j++)
A[++np] = B[j];
}
for (int i = 1; i <= S; i++)
ans[i] = 0;
for (int i = 1; i <= np; i++){
ans[abs (S - a[I] - 2 * A[i])] = 1;
//cout<<I<<" "<<A[i]<<" "<<abs (S - a[I] - 2 * A[i])<<endl;
}
for (int i = 1; i <= S; i++)
ANS[i] += ans[i];
//cout<<endl;
}
np = 0;
for (int i = 1; i <= S; i++)
if (ANS[i] == n)
A[++np] = i;
cout<<np<<endl;
for (int i = 1; i <= np; i++)
cout<<A[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... |