답안 #333691

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333691 2020-12-07T13:54:57 Z beksultan04 Bootfall (IZhO17_bootfall) C++14
13 / 100
1000 ms 620 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 ((sum-q[i]+x)/2 >= x && dp[(sum-q[i]+x)/2-x]==0 || (sum-q[i]+x)/2 < x){
            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 || sum&1){
        cout <<0;
        ret 0;
    }
    vector <int> ans;
    for (x=1;x<sum;++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: In function 'bool is(long long int)':
bootfall.cpp:38:33: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   38 |         if ((sum-q[i]+x)/2 >= x && dp[(sum-q[i]+x)/2-x]==0 || (sum-q[i]+x)/2 < x){
      |             ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
bootfall.cpp: At global scope:
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 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 13 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 19 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 13 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 19 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 5 ms 364 KB Output is correct
11 Correct 30 ms 512 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 22 ms 364 KB Output is correct
15 Correct 23 ms 364 KB Output is correct
16 Correct 25 ms 364 KB Output is correct
17 Correct 10 ms 364 KB Output is correct
18 Correct 16 ms 364 KB Output is correct
19 Correct 15 ms 364 KB Output is correct
20 Correct 5 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 13 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 19 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 5 ms 364 KB Output is correct
11 Correct 30 ms 512 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 22 ms 364 KB Output is correct
15 Correct 23 ms 364 KB Output is correct
16 Correct 25 ms 364 KB Output is correct
17 Correct 10 ms 364 KB Output is correct
18 Correct 16 ms 364 KB Output is correct
19 Correct 15 ms 364 KB Output is correct
20 Correct 5 ms 364 KB Output is correct
21 Correct 548 ms 364 KB Output is correct
22 Correct 706 ms 492 KB Output is correct
23 Correct 318 ms 492 KB Output is correct
24 Execution timed out 1093 ms 620 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 13 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 19 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 5 ms 364 KB Output is correct
11 Correct 30 ms 512 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 22 ms 364 KB Output is correct
15 Correct 23 ms 364 KB Output is correct
16 Correct 25 ms 364 KB Output is correct
17 Correct 10 ms 364 KB Output is correct
18 Correct 16 ms 364 KB Output is correct
19 Correct 15 ms 364 KB Output is correct
20 Correct 5 ms 364 KB Output is correct
21 Correct 548 ms 364 KB Output is correct
22 Correct 706 ms 492 KB Output is correct
23 Correct 318 ms 492 KB Output is correct
24 Execution timed out 1093 ms 620 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 13 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 19 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 5 ms 364 KB Output is correct
11 Correct 30 ms 512 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 22 ms 364 KB Output is correct
15 Correct 23 ms 364 KB Output is correct
16 Correct 25 ms 364 KB Output is correct
17 Correct 10 ms 364 KB Output is correct
18 Correct 16 ms 364 KB Output is correct
19 Correct 15 ms 364 KB Output is correct
20 Correct 5 ms 364 KB Output is correct
21 Correct 548 ms 364 KB Output is correct
22 Correct 706 ms 492 KB Output is correct
23 Correct 318 ms 492 KB Output is correct
24 Execution timed out 1093 ms 620 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 13 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 19 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 5 ms 364 KB Output is correct
11 Correct 30 ms 512 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 22 ms 364 KB Output is correct
15 Correct 23 ms 364 KB Output is correct
16 Correct 25 ms 364 KB Output is correct
17 Correct 10 ms 364 KB Output is correct
18 Correct 16 ms 364 KB Output is correct
19 Correct 15 ms 364 KB Output is correct
20 Correct 5 ms 364 KB Output is correct
21 Correct 548 ms 364 KB Output is correct
22 Correct 706 ms 492 KB Output is correct
23 Correct 318 ms 492 KB Output is correct
24 Execution timed out 1093 ms 620 KB Time limit exceeded
25 Halted 0 ms 0 KB -