Submission #575090

# Submission time Handle Problem Language Result Execution time Memory
575090 2022-06-09T16:30:20 Z MohammadAghil Bootfall (IZhO17_bootfall) C++14
44 / 100
1000 ms 11936 KB
      #include <bits/stdc++.h>
//   #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("avx2")
    using namespace std;
  typedef long long ll;
   typedef pair<int, int> pp;
    #define er(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << endl
      #define per(i,r,l) for(int i = (r); i >= (l); i--)
        #define rep(i,l,r) for(int i = (l); i < (r); i++)
           #define all(x) x.begin(), x.end()
              #define sz(x) (int)(x).size()
                  #define pb push_back
                      #define ss second
                           #define ff first
                                   void err(istringstream *iss){}template<typename T,typename ...Args> void err(istringstream *iss,const T &_val, const Args&...args){string _name;*iss>>_name;if(_name.back()==',')_name.pop_back();cerr<<_name<<" = "<<_val<<", ",err(iss,args...);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod = 1e9 + 7, maxn = 5e2+5, lg = 20, inf = ll(1e9) + 5;
ll pw(ll a,ll b,ll md=mod){if(!b)return 1;ll k=pw(a,b>>1ll);return k*k%md*(b&1ll?a:1)%md;}

bitset<maxn*maxn> dp[maxn];

int main(){
     cin.tie(0) -> sync_with_stdio(0);
     int n; cin >> n;
     vector<int> a(n);
     int sum = 0;
     rep(i,0,n) cin >> a[i], sum += a[i];
     rep(k,0,n+1){
          dp[k][0] = true;
          rep(i,0,n){
               if(i == k) continue;
               dp[k] |= dp[k]<<a[i];
          }
     }
     if((sum&1) || !dp[n][sum>>1]) return cout << "0\n", 0;
     rep(i,0,n) if(a[i]%2 != a[0]%2) return cout << "0\n", 0;
     vector<int> ans;
     rep(i,1,sum+1) if(i%2 == a[0]%2){
          bool ok = true;
          rep(j,0,n){
               int t = (sum - a[j] + i)>>1;
               if(t > sum || !dp[j][t]) {
                    ok = false;
                    break;
               }
          }
          if(ok) ans.pb(i);
     }
     cout << sz(ans) << '\n';
     for(int c: ans) cout << c << ' ';
     if(sz(ans)) cout << '\n';
     return 0; 
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 516 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 516 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 8 ms 1236 KB Output is correct
11 Correct 8 ms 1236 KB Output is correct
12 Correct 8 ms 1236 KB Output is correct
13 Correct 6 ms 1236 KB Output is correct
14 Correct 7 ms 1212 KB Output is correct
15 Correct 7 ms 1304 KB Output is correct
16 Correct 8 ms 1236 KB Output is correct
17 Correct 3 ms 980 KB Output is correct
18 Correct 5 ms 1108 KB Output is correct
19 Correct 7 ms 1108 KB Output is correct
20 Correct 9 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 516 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 8 ms 1236 KB Output is correct
11 Correct 8 ms 1236 KB Output is correct
12 Correct 8 ms 1236 KB Output is correct
13 Correct 6 ms 1236 KB Output is correct
14 Correct 7 ms 1212 KB Output is correct
15 Correct 7 ms 1304 KB Output is correct
16 Correct 8 ms 1236 KB Output is correct
17 Correct 3 ms 980 KB Output is correct
18 Correct 5 ms 1108 KB Output is correct
19 Correct 7 ms 1108 KB Output is correct
20 Correct 9 ms 1236 KB Output is correct
21 Correct 34 ms 2420 KB Output is correct
22 Correct 43 ms 2616 KB Output is correct
23 Correct 21 ms 1984 KB Output is correct
24 Correct 105 ms 3368 KB Output is correct
25 Correct 99 ms 3328 KB Output is correct
26 Correct 78 ms 3524 KB Output is correct
27 Correct 79 ms 3468 KB Output is correct
28 Correct 81 ms 3536 KB Output is correct
29 Correct 81 ms 3504 KB Output is correct
30 Correct 113 ms 3404 KB Output is correct
31 Correct 80 ms 3456 KB Output is correct
32 Correct 82 ms 3532 KB Output is correct
33 Correct 91 ms 3432 KB Output is correct
34 Correct 83 ms 3400 KB Output is correct
35 Correct 90 ms 3456 KB Output is correct
36 Correct 82 ms 3532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 516 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 8 ms 1236 KB Output is correct
11 Correct 8 ms 1236 KB Output is correct
12 Correct 8 ms 1236 KB Output is correct
13 Correct 6 ms 1236 KB Output is correct
14 Correct 7 ms 1212 KB Output is correct
15 Correct 7 ms 1304 KB Output is correct
16 Correct 8 ms 1236 KB Output is correct
17 Correct 3 ms 980 KB Output is correct
18 Correct 5 ms 1108 KB Output is correct
19 Correct 7 ms 1108 KB Output is correct
20 Correct 9 ms 1236 KB Output is correct
21 Correct 34 ms 2420 KB Output is correct
22 Correct 43 ms 2616 KB Output is correct
23 Correct 21 ms 1984 KB Output is correct
24 Correct 105 ms 3368 KB Output is correct
25 Correct 99 ms 3328 KB Output is correct
26 Correct 78 ms 3524 KB Output is correct
27 Correct 79 ms 3468 KB Output is correct
28 Correct 81 ms 3536 KB Output is correct
29 Correct 81 ms 3504 KB Output is correct
30 Correct 113 ms 3404 KB Output is correct
31 Correct 80 ms 3456 KB Output is correct
32 Correct 82 ms 3532 KB Output is correct
33 Correct 91 ms 3432 KB Output is correct
34 Correct 83 ms 3400 KB Output is correct
35 Correct 90 ms 3456 KB Output is correct
36 Correct 82 ms 3532 KB Output is correct
37 Correct 320 ms 6788 KB Output is correct
38 Correct 325 ms 6732 KB Output is correct
39 Correct 544 ms 8188 KB Output is correct
40 Correct 632 ms 9128 KB Output is correct
41 Correct 577 ms 8924 KB Output is correct
42 Correct 495 ms 8304 KB Output is correct
43 Correct 520 ms 8396 KB Output is correct
44 Correct 514 ms 8452 KB Output is correct
45 Correct 541 ms 8552 KB Output is correct
46 Correct 601 ms 8800 KB Output is correct
47 Correct 514 ms 8356 KB Output is correct
48 Correct 496 ms 8408 KB Output is correct
49 Correct 506 ms 8212 KB Output is correct
50 Correct 515 ms 8388 KB Output is correct
51 Correct 468 ms 8136 KB Output is correct
52 Correct 616 ms 9224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 516 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 8 ms 1236 KB Output is correct
11 Correct 8 ms 1236 KB Output is correct
12 Correct 8 ms 1236 KB Output is correct
13 Correct 6 ms 1236 KB Output is correct
14 Correct 7 ms 1212 KB Output is correct
15 Correct 7 ms 1304 KB Output is correct
16 Correct 8 ms 1236 KB Output is correct
17 Correct 3 ms 980 KB Output is correct
18 Correct 5 ms 1108 KB Output is correct
19 Correct 7 ms 1108 KB Output is correct
20 Correct 9 ms 1236 KB Output is correct
21 Correct 34 ms 2420 KB Output is correct
22 Correct 43 ms 2616 KB Output is correct
23 Correct 21 ms 1984 KB Output is correct
24 Correct 105 ms 3368 KB Output is correct
25 Correct 99 ms 3328 KB Output is correct
26 Correct 78 ms 3524 KB Output is correct
27 Correct 79 ms 3468 KB Output is correct
28 Correct 81 ms 3536 KB Output is correct
29 Correct 81 ms 3504 KB Output is correct
30 Correct 113 ms 3404 KB Output is correct
31 Correct 80 ms 3456 KB Output is correct
32 Correct 82 ms 3532 KB Output is correct
33 Correct 91 ms 3432 KB Output is correct
34 Correct 83 ms 3400 KB Output is correct
35 Correct 90 ms 3456 KB Output is correct
36 Correct 82 ms 3532 KB Output is correct
37 Correct 320 ms 6788 KB Output is correct
38 Correct 325 ms 6732 KB Output is correct
39 Correct 544 ms 8188 KB Output is correct
40 Correct 632 ms 9128 KB Output is correct
41 Correct 577 ms 8924 KB Output is correct
42 Correct 495 ms 8304 KB Output is correct
43 Correct 520 ms 8396 KB Output is correct
44 Correct 514 ms 8452 KB Output is correct
45 Correct 541 ms 8552 KB Output is correct
46 Correct 601 ms 8800 KB Output is correct
47 Correct 514 ms 8356 KB Output is correct
48 Correct 496 ms 8408 KB Output is correct
49 Correct 506 ms 8212 KB Output is correct
50 Correct 515 ms 8388 KB Output is correct
51 Correct 468 ms 8136 KB Output is correct
52 Correct 616 ms 9224 KB Output is correct
53 Correct 734 ms 10168 KB Output is correct
54 Correct 996 ms 11648 KB Output is correct
55 Execution timed out 1008 ms 11936 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 516 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 8 ms 1236 KB Output is correct
11 Correct 8 ms 1236 KB Output is correct
12 Correct 8 ms 1236 KB Output is correct
13 Correct 6 ms 1236 KB Output is correct
14 Correct 7 ms 1212 KB Output is correct
15 Correct 7 ms 1304 KB Output is correct
16 Correct 8 ms 1236 KB Output is correct
17 Correct 3 ms 980 KB Output is correct
18 Correct 5 ms 1108 KB Output is correct
19 Correct 7 ms 1108 KB Output is correct
20 Correct 9 ms 1236 KB Output is correct
21 Correct 34 ms 2420 KB Output is correct
22 Correct 43 ms 2616 KB Output is correct
23 Correct 21 ms 1984 KB Output is correct
24 Correct 105 ms 3368 KB Output is correct
25 Correct 99 ms 3328 KB Output is correct
26 Correct 78 ms 3524 KB Output is correct
27 Correct 79 ms 3468 KB Output is correct
28 Correct 81 ms 3536 KB Output is correct
29 Correct 81 ms 3504 KB Output is correct
30 Correct 113 ms 3404 KB Output is correct
31 Correct 80 ms 3456 KB Output is correct
32 Correct 82 ms 3532 KB Output is correct
33 Correct 91 ms 3432 KB Output is correct
34 Correct 83 ms 3400 KB Output is correct
35 Correct 90 ms 3456 KB Output is correct
36 Correct 82 ms 3532 KB Output is correct
37 Correct 320 ms 6788 KB Output is correct
38 Correct 325 ms 6732 KB Output is correct
39 Correct 544 ms 8188 KB Output is correct
40 Correct 632 ms 9128 KB Output is correct
41 Correct 577 ms 8924 KB Output is correct
42 Correct 495 ms 8304 KB Output is correct
43 Correct 520 ms 8396 KB Output is correct
44 Correct 514 ms 8452 KB Output is correct
45 Correct 541 ms 8552 KB Output is correct
46 Correct 601 ms 8800 KB Output is correct
47 Correct 514 ms 8356 KB Output is correct
48 Correct 496 ms 8408 KB Output is correct
49 Correct 506 ms 8212 KB Output is correct
50 Correct 515 ms 8388 KB Output is correct
51 Correct 468 ms 8136 KB Output is correct
52 Correct 616 ms 9224 KB Output is correct
53 Correct 734 ms 10168 KB Output is correct
54 Correct 996 ms 11648 KB Output is correct
55 Execution timed out 1008 ms 11936 KB Time limit exceeded
56 Halted 0 ms 0 KB -