답안 #575092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
575092 2022-06-09T16:32:40 Z MohammadAghil Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 13396 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; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 468 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 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 468 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 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 676 KB Output is correct
10 Correct 8 ms 1272 KB Output is correct
11 Correct 11 ms 1272 KB Output is correct
12 Correct 6 ms 1236 KB Output is correct
13 Correct 5 ms 1236 KB Output is correct
14 Correct 5 ms 1236 KB Output is correct
15 Correct 6 ms 1236 KB Output is correct
16 Correct 6 ms 1236 KB Output is correct
17 Correct 3 ms 980 KB Output is correct
18 Correct 4 ms 1108 KB Output is correct
19 Correct 5 ms 1108 KB Output is correct
20 Correct 6 ms 1236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 468 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 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 676 KB Output is correct
10 Correct 8 ms 1272 KB Output is correct
11 Correct 11 ms 1272 KB Output is correct
12 Correct 6 ms 1236 KB Output is correct
13 Correct 5 ms 1236 KB Output is correct
14 Correct 5 ms 1236 KB Output is correct
15 Correct 6 ms 1236 KB Output is correct
16 Correct 6 ms 1236 KB Output is correct
17 Correct 3 ms 980 KB Output is correct
18 Correct 4 ms 1108 KB Output is correct
19 Correct 5 ms 1108 KB Output is correct
20 Correct 6 ms 1236 KB Output is correct
21 Correct 28 ms 2380 KB Output is correct
22 Correct 47 ms 2656 KB Output is correct
23 Correct 16 ms 1960 KB Output is correct
24 Correct 54 ms 3332 KB Output is correct
25 Correct 62 ms 3292 KB Output is correct
26 Correct 73 ms 3452 KB Output is correct
27 Correct 64 ms 3512 KB Output is correct
28 Correct 73 ms 3540 KB Output is correct
29 Correct 75 ms 3496 KB Output is correct
30 Correct 67 ms 3528 KB Output is correct
31 Correct 69 ms 3472 KB Output is correct
32 Correct 67 ms 3524 KB Output is correct
33 Correct 62 ms 3524 KB Output is correct
34 Correct 72 ms 3492 KB Output is correct
35 Correct 71 ms 3448 KB Output is correct
36 Correct 81 ms 3548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 468 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 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 676 KB Output is correct
10 Correct 8 ms 1272 KB Output is correct
11 Correct 11 ms 1272 KB Output is correct
12 Correct 6 ms 1236 KB Output is correct
13 Correct 5 ms 1236 KB Output is correct
14 Correct 5 ms 1236 KB Output is correct
15 Correct 6 ms 1236 KB Output is correct
16 Correct 6 ms 1236 KB Output is correct
17 Correct 3 ms 980 KB Output is correct
18 Correct 4 ms 1108 KB Output is correct
19 Correct 5 ms 1108 KB Output is correct
20 Correct 6 ms 1236 KB Output is correct
21 Correct 28 ms 2380 KB Output is correct
22 Correct 47 ms 2656 KB Output is correct
23 Correct 16 ms 1960 KB Output is correct
24 Correct 54 ms 3332 KB Output is correct
25 Correct 62 ms 3292 KB Output is correct
26 Correct 73 ms 3452 KB Output is correct
27 Correct 64 ms 3512 KB Output is correct
28 Correct 73 ms 3540 KB Output is correct
29 Correct 75 ms 3496 KB Output is correct
30 Correct 67 ms 3528 KB Output is correct
31 Correct 69 ms 3472 KB Output is correct
32 Correct 67 ms 3524 KB Output is correct
33 Correct 62 ms 3524 KB Output is correct
34 Correct 72 ms 3492 KB Output is correct
35 Correct 71 ms 3448 KB Output is correct
36 Correct 81 ms 3548 KB Output is correct
37 Correct 255 ms 6780 KB Output is correct
38 Correct 268 ms 6684 KB Output is correct
39 Correct 366 ms 8048 KB Output is correct
40 Correct 461 ms 8964 KB Output is correct
41 Correct 494 ms 8888 KB Output is correct
42 Correct 425 ms 8328 KB Output is correct
43 Correct 370 ms 8372 KB Output is correct
44 Correct 415 ms 8448 KB Output is correct
45 Correct 388 ms 8564 KB Output is correct
46 Correct 473 ms 8804 KB Output is correct
47 Correct 382 ms 8412 KB Output is correct
48 Correct 407 ms 8448 KB Output is correct
49 Correct 382 ms 8308 KB Output is correct
50 Correct 411 ms 8388 KB Output is correct
51 Correct 396 ms 8160 KB Output is correct
52 Correct 460 ms 9228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 468 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 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 676 KB Output is correct
10 Correct 8 ms 1272 KB Output is correct
11 Correct 11 ms 1272 KB Output is correct
12 Correct 6 ms 1236 KB Output is correct
13 Correct 5 ms 1236 KB Output is correct
14 Correct 5 ms 1236 KB Output is correct
15 Correct 6 ms 1236 KB Output is correct
16 Correct 6 ms 1236 KB Output is correct
17 Correct 3 ms 980 KB Output is correct
18 Correct 4 ms 1108 KB Output is correct
19 Correct 5 ms 1108 KB Output is correct
20 Correct 6 ms 1236 KB Output is correct
21 Correct 28 ms 2380 KB Output is correct
22 Correct 47 ms 2656 KB Output is correct
23 Correct 16 ms 1960 KB Output is correct
24 Correct 54 ms 3332 KB Output is correct
25 Correct 62 ms 3292 KB Output is correct
26 Correct 73 ms 3452 KB Output is correct
27 Correct 64 ms 3512 KB Output is correct
28 Correct 73 ms 3540 KB Output is correct
29 Correct 75 ms 3496 KB Output is correct
30 Correct 67 ms 3528 KB Output is correct
31 Correct 69 ms 3472 KB Output is correct
32 Correct 67 ms 3524 KB Output is correct
33 Correct 62 ms 3524 KB Output is correct
34 Correct 72 ms 3492 KB Output is correct
35 Correct 71 ms 3448 KB Output is correct
36 Correct 81 ms 3548 KB Output is correct
37 Correct 255 ms 6780 KB Output is correct
38 Correct 268 ms 6684 KB Output is correct
39 Correct 366 ms 8048 KB Output is correct
40 Correct 461 ms 8964 KB Output is correct
41 Correct 494 ms 8888 KB Output is correct
42 Correct 425 ms 8328 KB Output is correct
43 Correct 370 ms 8372 KB Output is correct
44 Correct 415 ms 8448 KB Output is correct
45 Correct 388 ms 8564 KB Output is correct
46 Correct 473 ms 8804 KB Output is correct
47 Correct 382 ms 8412 KB Output is correct
48 Correct 407 ms 8448 KB Output is correct
49 Correct 382 ms 8308 KB Output is correct
50 Correct 411 ms 8388 KB Output is correct
51 Correct 396 ms 8160 KB Output is correct
52 Correct 460 ms 9228 KB Output is correct
53 Correct 602 ms 10000 KB Output is correct
54 Correct 799 ms 11708 KB Output is correct
55 Correct 780 ms 12036 KB Output is correct
56 Correct 665 ms 10232 KB Output is correct
57 Correct 787 ms 11972 KB Output is correct
58 Correct 808 ms 11756 KB Output is correct
59 Correct 801 ms 11976 KB Output is correct
60 Correct 784 ms 11336 KB Output is correct
61 Correct 772 ms 11868 KB Output is correct
62 Correct 660 ms 11028 KB Output is correct
63 Correct 698 ms 10920 KB Output is correct
64 Correct 672 ms 10704 KB Output is correct
65 Correct 609 ms 10332 KB Output is correct
66 Correct 580 ms 10076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 468 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 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 676 KB Output is correct
10 Correct 8 ms 1272 KB Output is correct
11 Correct 11 ms 1272 KB Output is correct
12 Correct 6 ms 1236 KB Output is correct
13 Correct 5 ms 1236 KB Output is correct
14 Correct 5 ms 1236 KB Output is correct
15 Correct 6 ms 1236 KB Output is correct
16 Correct 6 ms 1236 KB Output is correct
17 Correct 3 ms 980 KB Output is correct
18 Correct 4 ms 1108 KB Output is correct
19 Correct 5 ms 1108 KB Output is correct
20 Correct 6 ms 1236 KB Output is correct
21 Correct 28 ms 2380 KB Output is correct
22 Correct 47 ms 2656 KB Output is correct
23 Correct 16 ms 1960 KB Output is correct
24 Correct 54 ms 3332 KB Output is correct
25 Correct 62 ms 3292 KB Output is correct
26 Correct 73 ms 3452 KB Output is correct
27 Correct 64 ms 3512 KB Output is correct
28 Correct 73 ms 3540 KB Output is correct
29 Correct 75 ms 3496 KB Output is correct
30 Correct 67 ms 3528 KB Output is correct
31 Correct 69 ms 3472 KB Output is correct
32 Correct 67 ms 3524 KB Output is correct
33 Correct 62 ms 3524 KB Output is correct
34 Correct 72 ms 3492 KB Output is correct
35 Correct 71 ms 3448 KB Output is correct
36 Correct 81 ms 3548 KB Output is correct
37 Correct 255 ms 6780 KB Output is correct
38 Correct 268 ms 6684 KB Output is correct
39 Correct 366 ms 8048 KB Output is correct
40 Correct 461 ms 8964 KB Output is correct
41 Correct 494 ms 8888 KB Output is correct
42 Correct 425 ms 8328 KB Output is correct
43 Correct 370 ms 8372 KB Output is correct
44 Correct 415 ms 8448 KB Output is correct
45 Correct 388 ms 8564 KB Output is correct
46 Correct 473 ms 8804 KB Output is correct
47 Correct 382 ms 8412 KB Output is correct
48 Correct 407 ms 8448 KB Output is correct
49 Correct 382 ms 8308 KB Output is correct
50 Correct 411 ms 8388 KB Output is correct
51 Correct 396 ms 8160 KB Output is correct
52 Correct 460 ms 9228 KB Output is correct
53 Correct 602 ms 10000 KB Output is correct
54 Correct 799 ms 11708 KB Output is correct
55 Correct 780 ms 12036 KB Output is correct
56 Correct 665 ms 10232 KB Output is correct
57 Correct 787 ms 11972 KB Output is correct
58 Correct 808 ms 11756 KB Output is correct
59 Correct 801 ms 11976 KB Output is correct
60 Correct 784 ms 11336 KB Output is correct
61 Correct 772 ms 11868 KB Output is correct
62 Correct 660 ms 11028 KB Output is correct
63 Correct 698 ms 10920 KB Output is correct
64 Correct 672 ms 10704 KB Output is correct
65 Correct 609 ms 10332 KB Output is correct
66 Correct 580 ms 10076 KB Output is correct
67 Execution timed out 1061 ms 13396 KB Time limit exceeded
68 Halted 0 ms 0 KB -