Submission #173080

# Submission time Handle Problem Language Result Execution time Memory
173080 2020-01-03T10:18:37 Z beksultan04 Bootfall (IZhO17_bootfall) C++14
13 / 100
1000 ms 632 KB
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define OK puts("OK");
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define all(s) s.begin(), s.end()
#define allr(s) s.rbegin(), s.rend()
#define rep(i,n) for (i=0;i<(n);++i)
#define rep1(i,n) for (i=1;i<=(n);++i)
#define ret return
#define nemeshay ios::sync_with_stdio(0),cin.tie(0);
const int N=1e6+12,INF=1e9+7;
int q[N],coor[N],n,ans;
bool is(){
    int dp[500*500+12],i,j,sum=0;
    for (i=0;i<ans*2;++i)dp[i]=0;
    dp[0]=1;
    rep(i,n){
        for (j=ans*2-1;j>=0;--j)
            if (dp[j]==1)
                dp[j+q[i]]=1;
        sum+=q[i];
    }
    if (sum%2==1 || dp[sum/2]==0)ret 0;
    ret 1;
}
main(){
    int i,j;
    cin>>n;
    vector <int> v;
    rep(i,n){
        cin>>q[i];
        ans+=q[i];
    }
    if (!is()){
        cout <<0;
        ret 0;
    }
    else {
        for (i=1;i<ans;++i){
            for (j=0;j<n;++j){
                int c=q[j];
                q[j]=i;
                if (!is()){
                    q[j]=c;
                    break;
                }
                else q[j]=c;
            }
            if (j==n)
                v.pb(i);

        }
        cout <<v.size()<<"\n";
        rep(i,v.size())
            cout <<v[i]<<" ";
    }
}

Compilation message

bootfall.cpp:31:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
bootfall.cpp: In function 'int main()':
bootfall.cpp:12:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i,n) for (i=0;i<(n);++i)
                            ^
bootfall.cpp:59:9: note: in expansion of macro 'rep'
         rep(i,v.size())
         ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
5 Correct 90 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 173 ms 632 KB Output is correct
9 Correct 12 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
5 Correct 90 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 173 ms 632 KB Output is correct
9 Correct 12 ms 376 KB Output is correct
10 Correct 36 ms 376 KB Output is correct
11 Correct 62 ms 416 KB Output is correct
12 Correct 14 ms 548 KB Output is correct
13 Correct 9 ms 376 KB Output is correct
14 Correct 71 ms 376 KB Output is correct
15 Correct 41 ms 376 KB Output is correct
16 Correct 60 ms 376 KB Output is correct
17 Correct 14 ms 376 KB Output is correct
18 Correct 38 ms 376 KB Output is correct
19 Correct 29 ms 420 KB Output is correct
20 Correct 43 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
5 Correct 90 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 173 ms 632 KB Output is correct
9 Correct 12 ms 376 KB Output is correct
10 Correct 36 ms 376 KB Output is correct
11 Correct 62 ms 416 KB Output is correct
12 Correct 14 ms 548 KB Output is correct
13 Correct 9 ms 376 KB Output is correct
14 Correct 71 ms 376 KB Output is correct
15 Correct 41 ms 376 KB Output is correct
16 Correct 60 ms 376 KB Output is correct
17 Correct 14 ms 376 KB Output is correct
18 Correct 38 ms 376 KB Output is correct
19 Correct 29 ms 420 KB Output is correct
20 Correct 43 ms 376 KB Output is correct
21 Execution timed out 1059 ms 376 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
5 Correct 90 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 173 ms 632 KB Output is correct
9 Correct 12 ms 376 KB Output is correct
10 Correct 36 ms 376 KB Output is correct
11 Correct 62 ms 416 KB Output is correct
12 Correct 14 ms 548 KB Output is correct
13 Correct 9 ms 376 KB Output is correct
14 Correct 71 ms 376 KB Output is correct
15 Correct 41 ms 376 KB Output is correct
16 Correct 60 ms 376 KB Output is correct
17 Correct 14 ms 376 KB Output is correct
18 Correct 38 ms 376 KB Output is correct
19 Correct 29 ms 420 KB Output is correct
20 Correct 43 ms 376 KB Output is correct
21 Execution timed out 1059 ms 376 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
5 Correct 90 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 173 ms 632 KB Output is correct
9 Correct 12 ms 376 KB Output is correct
10 Correct 36 ms 376 KB Output is correct
11 Correct 62 ms 416 KB Output is correct
12 Correct 14 ms 548 KB Output is correct
13 Correct 9 ms 376 KB Output is correct
14 Correct 71 ms 376 KB Output is correct
15 Correct 41 ms 376 KB Output is correct
16 Correct 60 ms 376 KB Output is correct
17 Correct 14 ms 376 KB Output is correct
18 Correct 38 ms 376 KB Output is correct
19 Correct 29 ms 420 KB Output is correct
20 Correct 43 ms 376 KB Output is correct
21 Execution timed out 1059 ms 376 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
5 Correct 90 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 173 ms 632 KB Output is correct
9 Correct 12 ms 376 KB Output is correct
10 Correct 36 ms 376 KB Output is correct
11 Correct 62 ms 416 KB Output is correct
12 Correct 14 ms 548 KB Output is correct
13 Correct 9 ms 376 KB Output is correct
14 Correct 71 ms 376 KB Output is correct
15 Correct 41 ms 376 KB Output is correct
16 Correct 60 ms 376 KB Output is correct
17 Correct 14 ms 376 KB Output is correct
18 Correct 38 ms 376 KB Output is correct
19 Correct 29 ms 420 KB Output is correct
20 Correct 43 ms 376 KB Output is correct
21 Execution timed out 1059 ms 376 KB Time limit exceeded
22 Halted 0 ms 0 KB -