답안 #334025

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
334025 2020-12-08T06:36:50 Z BY_KUTBILIM Bootfall (IZhO17_bootfall) C++14
0 / 100
25 ms 3176 KB
/** @BY_KUTBILIM **/
#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define ll long long

const int N = 510;
int sum = 0;
int dp[N*N], cant[N*N];
int add(int x){
    for(int i = sum; i >= 0; i--){
        dp[i+x] += dp[i];
    }
    sum += x;
}

int sub(int x){
    sum -= x;
    for(int i = 0; i <= sum; i++){
        dp[i+x] -= dp[i];
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie();

    int n;
    int a[n];
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        add(a[i]);
    }
    if(sum % 2 != 0 || !dp[sum/2]){
        cout << 0;
        return 0;
    }
    for(int i = 0; i < n; i++){
        sub(a[i]);
        for(int j = 0; j <= 250000; j++){
            if((sum + j) % 2 != 0 || !dp[(sum+j)/2])cant[j] = 1;
        }
    }
    vector<int> ans;
    for(int i = 0; i <= 250000; i++){
        if(!cant[i])ans.pb(i);
    }
    cout << ans.size() << endl;
    for(auto i : ans){
        cout << i << " ";
    }
    cout << endl;

    return 0;
}

Compilation message

bootfall.cpp: In function 'int add(int)':
bootfall.cpp:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
   18 | }
      | ^
bootfall.cpp: In function 'int sub(int)':
bootfall.cpp:25:1: warning: no return statement in function returning non-void [-Wreturn-type]
   25 | }
      | ^
bootfall.cpp: In function 'int main()':
bootfall.cpp:31:9: warning: 'n' is used uninitialized in this function [-Wuninitialized]
   31 |     int n;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 3176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 3176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 3176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 3176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 3176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 3176 KB Output isn't correct
2 Halted 0 ms 0 KB -