| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 167369 | GioChkhaidze | Bootfall (IZhO17_bootfall) | C++14 | 1067 ms | 3536 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=505;
int n,S,a[N];
ll dp[N*N],mod=1e9+7;
vector < int > ans;
bitset < N*N > A,B,C;
main () {
cin>>n;
for (int i=1; i<=n; i++) {
cin>>a[i];
S+=a[i];
}
sort(a+1,a+n+1);
dp[0]=1;
for (int i=1; i<=n; i++)
for (int j=S-a[i]; j>=0; j--) {
dp[j+a[i]]+=dp[j];
if (dp[j+a[i]]>mod) dp[j+a[i]]-=mod;
}
if (S%2 || !dp[S/2]) {
cout<<0<<endl;
return 0;
}
for (int i=1; i<=S; i++)
C[i]=1;
for (int i=1; i<=n; i++) {
for (int j=a[i]; j<=S; j++) {
dp[j]-=dp[j-a[i]];
if (dp[j]<0) dp[j]+=mod;
}
for (int j=1; j<=S; j++) {
int X=j,Y=S-a[i]-j;
if (Y<0) continue;
if (!dp[X] && !dp[Y]) continue;
A[abs(X-Y)]=1;
}
C=A&C;
for (int j=1; j<=S; j++)
A[j]=0;
for (int j=S-a[i]; j>=0; j--) {
dp[j+a[i]]+=dp[j];
if (dp[j+a[i]]>mod) dp[j+a[i]]-=mod;
}
}
for (int i=1; i<=S; i++)
if (C[i]) ans.push_back(i);
cout<<ans.size()<<endl;
for (int i=0; i<ans.size(); i++)
cout<<ans[i]<<" ";
}
컴파일 시 표준 에러 (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... | ||||
