Submission #566488

# Submission time Handle Problem Language Result Execution time Memory
566488 2022-05-22T10:59:26 Z Uzouf Bootfall (IZhO17_bootfall) C++14
100 / 100
723 ms 5784 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#include "xylophone.h"
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl "\n"
int mod=672894013467956;//1e9+7;
const int N=505;//2e5+5;
const int M=250005;
template<class x>
using ordered_multiset = tree<x, null_type,less_equal<x>, rb_tree_tag,tree_order_statistics_node_update>;

int n,sum;
int v[N],dp[M],kk[M];
vector<int> ans;

void remove(int nm) {
  for (int j=nm;j<=M;j++) {
    dp[j]-=dp[j-nm];
    if (dp[j]>=mod) dp[j]%=mod;
  }
}

void add(int nm) {
  for (int j=M;j>=nm;j--) {
    dp[j]+=dp[j-nm];
    if (dp[j]>=mod) dp[j]%=mod;
  }
}

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(".in", "r", stdin); freopen(".out", "w", stdout);

    cin>>n;
    for (int i=0;i<n;i++) {
      cin>>v[i];
      sum+=v[i];
    }

    dp[0]=1;
    for (int i=0;i<n;i++) {
      for (int j=M;j>=v[i];j--) {
        dp[j]+=dp[j-v[i]];
        if (dp[j]>=mod) dp[j]%=mod;
      }
    }

    if (dp[sum/2]==0 || sum%2!=0) {
      cout<<0;
      return 0;
    }

    for (int i=1;i<=sum;i++) {
      kk[i]=1;
    }

    for (int i=0;i<n;i++) {
      remove(v[i]);
      for (int j=1;j<=sum;j++) {
        int nw=sum-v[i]+j;
        if (nw/2<j) {kk[j]=0; continue;}
        if (dp[(nw/2)-j]==0 || (j+v[i])%2!=0) kk[j]=0;
      }
      add(v[i]);
    }

    for(int i=1;i<=M;i++) {
      if (kk[i]==1) ans.push_back(i);
    }

    cout<<ans.size()<<endl;
    for (int i:ans) cout<<i<<' ';
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2260 KB Output is correct
2 Correct 5 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 5 ms 2260 KB Output is correct
5 Correct 13 ms 2260 KB Output is correct
6 Correct 9 ms 2260 KB Output is correct
7 Correct 6 ms 2260 KB Output is correct
8 Correct 12 ms 2260 KB Output is correct
9 Correct 8 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2260 KB Output is correct
2 Correct 5 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 5 ms 2260 KB Output is correct
5 Correct 13 ms 2260 KB Output is correct
6 Correct 9 ms 2260 KB Output is correct
7 Correct 6 ms 2260 KB Output is correct
8 Correct 12 ms 2260 KB Output is correct
9 Correct 8 ms 2260 KB Output is correct
10 Correct 24 ms 2268 KB Output is correct
11 Correct 22 ms 2288 KB Output is correct
12 Correct 22 ms 2288 KB Output is correct
13 Correct 17 ms 2184 KB Output is correct
14 Correct 18 ms 2288 KB Output is correct
15 Correct 20 ms 2284 KB Output is correct
16 Correct 22 ms 2292 KB Output is correct
17 Correct 16 ms 2288 KB Output is correct
18 Correct 18 ms 2296 KB Output is correct
19 Correct 18 ms 2288 KB Output is correct
20 Correct 27 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2260 KB Output is correct
2 Correct 5 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 5 ms 2260 KB Output is correct
5 Correct 13 ms 2260 KB Output is correct
6 Correct 9 ms 2260 KB Output is correct
7 Correct 6 ms 2260 KB Output is correct
8 Correct 12 ms 2260 KB Output is correct
9 Correct 8 ms 2260 KB Output is correct
10 Correct 24 ms 2268 KB Output is correct
11 Correct 22 ms 2288 KB Output is correct
12 Correct 22 ms 2288 KB Output is correct
13 Correct 17 ms 2184 KB Output is correct
14 Correct 18 ms 2288 KB Output is correct
15 Correct 20 ms 2284 KB Output is correct
16 Correct 22 ms 2292 KB Output is correct
17 Correct 16 ms 2288 KB Output is correct
18 Correct 18 ms 2296 KB Output is correct
19 Correct 18 ms 2288 KB Output is correct
20 Correct 27 ms 2260 KB Output is correct
21 Correct 38 ms 2284 KB Output is correct
22 Correct 45 ms 2304 KB Output is correct
23 Correct 32 ms 2308 KB Output is correct
24 Correct 73 ms 2304 KB Output is correct
25 Correct 56 ms 2380 KB Output is correct
26 Correct 57 ms 2344 KB Output is correct
27 Correct 69 ms 2332 KB Output is correct
28 Correct 58 ms 2356 KB Output is correct
29 Correct 64 ms 2280 KB Output is correct
30 Correct 62 ms 2308 KB Output is correct
31 Correct 55 ms 2336 KB Output is correct
32 Correct 55 ms 2300 KB Output is correct
33 Correct 59 ms 2344 KB Output is correct
34 Correct 55 ms 2260 KB Output is correct
35 Correct 56 ms 2356 KB Output is correct
36 Correct 62 ms 2268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2260 KB Output is correct
2 Correct 5 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 5 ms 2260 KB Output is correct
5 Correct 13 ms 2260 KB Output is correct
6 Correct 9 ms 2260 KB Output is correct
7 Correct 6 ms 2260 KB Output is correct
8 Correct 12 ms 2260 KB Output is correct
9 Correct 8 ms 2260 KB Output is correct
10 Correct 24 ms 2268 KB Output is correct
11 Correct 22 ms 2288 KB Output is correct
12 Correct 22 ms 2288 KB Output is correct
13 Correct 17 ms 2184 KB Output is correct
14 Correct 18 ms 2288 KB Output is correct
15 Correct 20 ms 2284 KB Output is correct
16 Correct 22 ms 2292 KB Output is correct
17 Correct 16 ms 2288 KB Output is correct
18 Correct 18 ms 2296 KB Output is correct
19 Correct 18 ms 2288 KB Output is correct
20 Correct 27 ms 2260 KB Output is correct
21 Correct 38 ms 2284 KB Output is correct
22 Correct 45 ms 2304 KB Output is correct
23 Correct 32 ms 2308 KB Output is correct
24 Correct 73 ms 2304 KB Output is correct
25 Correct 56 ms 2380 KB Output is correct
26 Correct 57 ms 2344 KB Output is correct
27 Correct 69 ms 2332 KB Output is correct
28 Correct 58 ms 2356 KB Output is correct
29 Correct 64 ms 2280 KB Output is correct
30 Correct 62 ms 2308 KB Output is correct
31 Correct 55 ms 2336 KB Output is correct
32 Correct 55 ms 2300 KB Output is correct
33 Correct 59 ms 2344 KB Output is correct
34 Correct 55 ms 2260 KB Output is correct
35 Correct 56 ms 2356 KB Output is correct
36 Correct 62 ms 2268 KB Output is correct
37 Correct 138 ms 2652 KB Output is correct
38 Correct 120 ms 2676 KB Output is correct
39 Correct 156 ms 2660 KB Output is correct
40 Correct 183 ms 2788 KB Output is correct
41 Correct 161 ms 2908 KB Output is correct
42 Correct 158 ms 2756 KB Output is correct
43 Correct 172 ms 3168 KB Output is correct
44 Correct 198 ms 3096 KB Output is correct
45 Correct 178 ms 3180 KB Output is correct
46 Correct 164 ms 2392 KB Output is correct
47 Correct 170 ms 2780 KB Output is correct
48 Correct 195 ms 3132 KB Output is correct
49 Correct 174 ms 2872 KB Output is correct
50 Correct 168 ms 2780 KB Output is correct
51 Correct 59 ms 2268 KB Output is correct
52 Correct 214 ms 3332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2260 KB Output is correct
2 Correct 5 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 5 ms 2260 KB Output is correct
5 Correct 13 ms 2260 KB Output is correct
6 Correct 9 ms 2260 KB Output is correct
7 Correct 6 ms 2260 KB Output is correct
8 Correct 12 ms 2260 KB Output is correct
9 Correct 8 ms 2260 KB Output is correct
10 Correct 24 ms 2268 KB Output is correct
11 Correct 22 ms 2288 KB Output is correct
12 Correct 22 ms 2288 KB Output is correct
13 Correct 17 ms 2184 KB Output is correct
14 Correct 18 ms 2288 KB Output is correct
15 Correct 20 ms 2284 KB Output is correct
16 Correct 22 ms 2292 KB Output is correct
17 Correct 16 ms 2288 KB Output is correct
18 Correct 18 ms 2296 KB Output is correct
19 Correct 18 ms 2288 KB Output is correct
20 Correct 27 ms 2260 KB Output is correct
21 Correct 38 ms 2284 KB Output is correct
22 Correct 45 ms 2304 KB Output is correct
23 Correct 32 ms 2308 KB Output is correct
24 Correct 73 ms 2304 KB Output is correct
25 Correct 56 ms 2380 KB Output is correct
26 Correct 57 ms 2344 KB Output is correct
27 Correct 69 ms 2332 KB Output is correct
28 Correct 58 ms 2356 KB Output is correct
29 Correct 64 ms 2280 KB Output is correct
30 Correct 62 ms 2308 KB Output is correct
31 Correct 55 ms 2336 KB Output is correct
32 Correct 55 ms 2300 KB Output is correct
33 Correct 59 ms 2344 KB Output is correct
34 Correct 55 ms 2260 KB Output is correct
35 Correct 56 ms 2356 KB Output is correct
36 Correct 62 ms 2268 KB Output is correct
37 Correct 138 ms 2652 KB Output is correct
38 Correct 120 ms 2676 KB Output is correct
39 Correct 156 ms 2660 KB Output is correct
40 Correct 183 ms 2788 KB Output is correct
41 Correct 161 ms 2908 KB Output is correct
42 Correct 158 ms 2756 KB Output is correct
43 Correct 172 ms 3168 KB Output is correct
44 Correct 198 ms 3096 KB Output is correct
45 Correct 178 ms 3180 KB Output is correct
46 Correct 164 ms 2392 KB Output is correct
47 Correct 170 ms 2780 KB Output is correct
48 Correct 195 ms 3132 KB Output is correct
49 Correct 174 ms 2872 KB Output is correct
50 Correct 168 ms 2780 KB Output is correct
51 Correct 59 ms 2268 KB Output is correct
52 Correct 214 ms 3332 KB Output is correct
53 Correct 221 ms 3012 KB Output is correct
54 Correct 258 ms 3184 KB Output is correct
55 Correct 352 ms 3904 KB Output is correct
56 Correct 227 ms 3220 KB Output is correct
57 Correct 336 ms 3948 KB Output is correct
58 Correct 270 ms 3264 KB Output is correct
59 Correct 300 ms 3504 KB Output is correct
60 Correct 104 ms 2268 KB Output is correct
61 Correct 315 ms 3576 KB Output is correct
62 Correct 300 ms 3780 KB Output is correct
63 Correct 304 ms 3804 KB Output is correct
64 Correct 276 ms 3836 KB Output is correct
65 Correct 192 ms 2648 KB Output is correct
66 Correct 192 ms 2812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2260 KB Output is correct
2 Correct 5 ms 2260 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 5 ms 2260 KB Output is correct
5 Correct 13 ms 2260 KB Output is correct
6 Correct 9 ms 2260 KB Output is correct
7 Correct 6 ms 2260 KB Output is correct
8 Correct 12 ms 2260 KB Output is correct
9 Correct 8 ms 2260 KB Output is correct
10 Correct 24 ms 2268 KB Output is correct
11 Correct 22 ms 2288 KB Output is correct
12 Correct 22 ms 2288 KB Output is correct
13 Correct 17 ms 2184 KB Output is correct
14 Correct 18 ms 2288 KB Output is correct
15 Correct 20 ms 2284 KB Output is correct
16 Correct 22 ms 2292 KB Output is correct
17 Correct 16 ms 2288 KB Output is correct
18 Correct 18 ms 2296 KB Output is correct
19 Correct 18 ms 2288 KB Output is correct
20 Correct 27 ms 2260 KB Output is correct
21 Correct 38 ms 2284 KB Output is correct
22 Correct 45 ms 2304 KB Output is correct
23 Correct 32 ms 2308 KB Output is correct
24 Correct 73 ms 2304 KB Output is correct
25 Correct 56 ms 2380 KB Output is correct
26 Correct 57 ms 2344 KB Output is correct
27 Correct 69 ms 2332 KB Output is correct
28 Correct 58 ms 2356 KB Output is correct
29 Correct 64 ms 2280 KB Output is correct
30 Correct 62 ms 2308 KB Output is correct
31 Correct 55 ms 2336 KB Output is correct
32 Correct 55 ms 2300 KB Output is correct
33 Correct 59 ms 2344 KB Output is correct
34 Correct 55 ms 2260 KB Output is correct
35 Correct 56 ms 2356 KB Output is correct
36 Correct 62 ms 2268 KB Output is correct
37 Correct 138 ms 2652 KB Output is correct
38 Correct 120 ms 2676 KB Output is correct
39 Correct 156 ms 2660 KB Output is correct
40 Correct 183 ms 2788 KB Output is correct
41 Correct 161 ms 2908 KB Output is correct
42 Correct 158 ms 2756 KB Output is correct
43 Correct 172 ms 3168 KB Output is correct
44 Correct 198 ms 3096 KB Output is correct
45 Correct 178 ms 3180 KB Output is correct
46 Correct 164 ms 2392 KB Output is correct
47 Correct 170 ms 2780 KB Output is correct
48 Correct 195 ms 3132 KB Output is correct
49 Correct 174 ms 2872 KB Output is correct
50 Correct 168 ms 2780 KB Output is correct
51 Correct 59 ms 2268 KB Output is correct
52 Correct 214 ms 3332 KB Output is correct
53 Correct 221 ms 3012 KB Output is correct
54 Correct 258 ms 3184 KB Output is correct
55 Correct 352 ms 3904 KB Output is correct
56 Correct 227 ms 3220 KB Output is correct
57 Correct 336 ms 3948 KB Output is correct
58 Correct 270 ms 3264 KB Output is correct
59 Correct 300 ms 3504 KB Output is correct
60 Correct 104 ms 2268 KB Output is correct
61 Correct 315 ms 3576 KB Output is correct
62 Correct 300 ms 3780 KB Output is correct
63 Correct 304 ms 3804 KB Output is correct
64 Correct 276 ms 3836 KB Output is correct
65 Correct 192 ms 2648 KB Output is correct
66 Correct 192 ms 2812 KB Output is correct
67 Correct 310 ms 3548 KB Output is correct
68 Correct 173 ms 2264 KB Output is correct
69 Correct 673 ms 5456 KB Output is correct
70 Correct 510 ms 4292 KB Output is correct
71 Correct 551 ms 4132 KB Output is correct
72 Correct 512 ms 3168 KB Output is correct
73 Correct 486 ms 3240 KB Output is correct
74 Correct 689 ms 5716 KB Output is correct
75 Correct 617 ms 4904 KB Output is correct
76 Correct 707 ms 5720 KB Output is correct
77 Correct 723 ms 5784 KB Output is correct