답안 #333679

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333679 2020-12-07T13:39:07 Z beksultan04 Bootfall (IZhO17_bootfall) C++14
0 / 100
86 ms 364 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
int a[N],b[N],q[N],dp[N],n,sum;

void add(int x){
    int i;
    for (i=5000;i>=0;--i){
        dp[i+x]+=dp[i];
    }
    ret ;
}

void del(int x){
    int i;
    for (i=0;i<=5000;++i){
        dp[i+x]-=dp[i];
    }
    ret ;
}

bool is(int x){
    int i;
    for (i=1;i<=n;++i){
        del(q[i]);
        if (dp[(sum-q[i]+x)/2-x]==0){
            add(q[i]);
            ret 0;
        }
        add(q[i]);
    }
    ret 1;
}

main(){
    int i,j,x;
    scan1(n)
    for (i=1;i<=n;++i)
        scan1(q[i])
    dp[0]=1;
    for (i=1;i<=n;++i){
        if (i!= 1 && q[i] %2 != q[i-1]%2){
            cout <<0;
            ret 0;
        }
        sum+=q[i];
        add(q[i]);
    }
    if (dp[sum/2]==0){
        cout <<0;
        ret 0;
    }
    vector <int> ans;
    for (x=1;x<5000;++x){
        if (x%2 == q[1]%2 && is(x))ans.pb(x);
    }
    cout <<ans.size()<<"\n";
    for (i=0;i<ans.size();++i){
        cout <<ans[i]<<" ";
    }
}








Compilation message

bootfall.cpp:47:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   47 | main(){
      |      ^
bootfall.cpp: In function 'int main()':
bootfall.cpp:70:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     for (i=0;i<ans.size();++i){
      |              ~^~~~~~~~~~~
bootfall.cpp:48:11: warning: unused variable 'j' [-Wunused-variable]
   48 |     int i,j,x;
      |           ^
bootfall.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
bootfall.cpp:49:5: note: in expansion of macro 'scan1'
   49 |     scan1(n)
      |     ^~~~~
bootfall.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
bootfall.cpp:51:9: note: in expansion of macro 'scan1'
   51 |         scan1(q[i])
      |         ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -