Submission #767191

# Submission time Handle Problem Language Result Execution time Memory
767191 2023-06-26T13:41:00 Z Trunkty Bootfall (IZhO17_bootfall) C++14
0 / 100
6 ms 4180 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll

int n,tot;
int arr[505],dp[250005],curr[250005];
bitset<250005> bs[505];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> arr[i];
        tot += arr[i];
    }
    dp[0] = 1;
    for(int i=1;i<=n;i++){
        for(int j=250000;j>=arr[i];j--){
            dp[j] += dp[j-arr[i]];
        }
    }
    if(tot%2 or dp[tot/2]==0){
        cout << 0 << "\n";
        cout << "\n";
        return 0;
    }
    for(int j=1;j<=n;j++){
        for(int i=0;i<=250000;i++){
            curr[i] = dp[i];
            if(i>=arr[j]){
                curr[i] -= curr[i-arr[j]];
            }
            if(curr[i]!=0){
                bs[j][i] = true;
            }
        }
    }
    vector<int> ans;
    for(int i=1;i<=250000;i++){
        bool yes = true;
        for(int j=1;j<=n;j++){
            if((tot-arr[j]+i)%2){
                yes = false;
                break;
            }
            int x = (tot-arr[j]+i)/2;
            if(dp[x]!=0){
                yes = false;
                break;
            }
            if(!bs[j][x]){
                yes = false;
                break;
            }
        }
        if(yes){
            ans.push_back(i);
        }
    }
    cout << ans.size() << "\n";
    for(int i:ans){
        cout << i << " ";
    }
    cout << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -