답안 #575094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
575094 2022-06-09T16:46:43 Z MohammadAghil Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 13388 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];
     int k = -1, f = 1;
     rep(i,0,n){
          int t = 0;
          while(a[i]%2 == 0) t++, a[i] >>= 1, f *= 1 + (k == -1);
          if(k == -1) k = t;
          if(t - k) return cout << "0\n", 0;
          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;
     vector<int> ans;
     rep(i,0,maxn*maxn) dp[n][i] = 1;
     rep(i,0,n) dp[i] >>= (sum - a[i] + 1)>>1, dp[n] &= dp[i];
     rep(i,0,sum+1) if(dp[n][i]) ans.pb((i<<1)+1);
     cout << sz(ans) << '\n';
     for(int c: ans) cout << c*f << ' ';
     if(sz(ans)) cout << '\n';
     return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 2 ms 724 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 2 ms 724 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 7 ms 1236 KB Output is correct
11 Correct 7 ms 1252 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 7 ms 1236 KB Output is correct
15 Correct 6 ms 1236 KB Output is correct
16 Correct 7 ms 1236 KB Output is correct
17 Correct 4 ms 980 KB Output is correct
18 Correct 5 ms 1048 KB Output is correct
19 Correct 6 ms 1232 KB Output is correct
20 Correct 8 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 2 ms 724 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 7 ms 1236 KB Output is correct
11 Correct 7 ms 1252 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 7 ms 1236 KB Output is correct
15 Correct 6 ms 1236 KB Output is correct
16 Correct 7 ms 1236 KB Output is correct
17 Correct 4 ms 980 KB Output is correct
18 Correct 5 ms 1048 KB Output is correct
19 Correct 6 ms 1232 KB Output is correct
20 Correct 8 ms 1364 KB Output is correct
21 Correct 30 ms 2388 KB Output is correct
22 Correct 38 ms 2732 KB Output is correct
23 Correct 17 ms 2004 KB Output is correct
24 Correct 56 ms 3288 KB Output is correct
25 Correct 57 ms 3372 KB Output is correct
26 Correct 70 ms 3452 KB Output is correct
27 Correct 67 ms 3532 KB Output is correct
28 Correct 64 ms 3516 KB Output is correct
29 Correct 67 ms 3560 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 76 ms 3456 KB Output is correct
32 Correct 68 ms 3548 KB Output is correct
33 Correct 74 ms 3440 KB Output is correct
34 Correct 62 ms 3468 KB Output is correct
35 Correct 72 ms 3464 KB Output is correct
36 Correct 69 ms 3452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 2 ms 724 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 7 ms 1236 KB Output is correct
11 Correct 7 ms 1252 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 7 ms 1236 KB Output is correct
15 Correct 6 ms 1236 KB Output is correct
16 Correct 7 ms 1236 KB Output is correct
17 Correct 4 ms 980 KB Output is correct
18 Correct 5 ms 1048 KB Output is correct
19 Correct 6 ms 1232 KB Output is correct
20 Correct 8 ms 1364 KB Output is correct
21 Correct 30 ms 2388 KB Output is correct
22 Correct 38 ms 2732 KB Output is correct
23 Correct 17 ms 2004 KB Output is correct
24 Correct 56 ms 3288 KB Output is correct
25 Correct 57 ms 3372 KB Output is correct
26 Correct 70 ms 3452 KB Output is correct
27 Correct 67 ms 3532 KB Output is correct
28 Correct 64 ms 3516 KB Output is correct
29 Correct 67 ms 3560 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 76 ms 3456 KB Output is correct
32 Correct 68 ms 3548 KB Output is correct
33 Correct 74 ms 3440 KB Output is correct
34 Correct 62 ms 3468 KB Output is correct
35 Correct 72 ms 3464 KB Output is correct
36 Correct 69 ms 3452 KB Output is correct
37 Correct 255 ms 6800 KB Output is correct
38 Correct 251 ms 6760 KB Output is correct
39 Correct 384 ms 8144 KB Output is correct
40 Correct 465 ms 8984 KB Output is correct
41 Correct 454 ms 8728 KB Output is correct
42 Correct 381 ms 8348 KB Output is correct
43 Correct 398 ms 8272 KB Output is correct
44 Correct 377 ms 8588 KB Output is correct
45 Correct 384 ms 8596 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 391 ms 8420 KB Output is correct
48 Correct 430 ms 8516 KB Output is correct
49 Correct 402 ms 8328 KB Output is correct
50 Correct 394 ms 8392 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 451 ms 9192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 2 ms 724 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 7 ms 1236 KB Output is correct
11 Correct 7 ms 1252 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 7 ms 1236 KB Output is correct
15 Correct 6 ms 1236 KB Output is correct
16 Correct 7 ms 1236 KB Output is correct
17 Correct 4 ms 980 KB Output is correct
18 Correct 5 ms 1048 KB Output is correct
19 Correct 6 ms 1232 KB Output is correct
20 Correct 8 ms 1364 KB Output is correct
21 Correct 30 ms 2388 KB Output is correct
22 Correct 38 ms 2732 KB Output is correct
23 Correct 17 ms 2004 KB Output is correct
24 Correct 56 ms 3288 KB Output is correct
25 Correct 57 ms 3372 KB Output is correct
26 Correct 70 ms 3452 KB Output is correct
27 Correct 67 ms 3532 KB Output is correct
28 Correct 64 ms 3516 KB Output is correct
29 Correct 67 ms 3560 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 76 ms 3456 KB Output is correct
32 Correct 68 ms 3548 KB Output is correct
33 Correct 74 ms 3440 KB Output is correct
34 Correct 62 ms 3468 KB Output is correct
35 Correct 72 ms 3464 KB Output is correct
36 Correct 69 ms 3452 KB Output is correct
37 Correct 255 ms 6800 KB Output is correct
38 Correct 251 ms 6760 KB Output is correct
39 Correct 384 ms 8144 KB Output is correct
40 Correct 465 ms 8984 KB Output is correct
41 Correct 454 ms 8728 KB Output is correct
42 Correct 381 ms 8348 KB Output is correct
43 Correct 398 ms 8272 KB Output is correct
44 Correct 377 ms 8588 KB Output is correct
45 Correct 384 ms 8596 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 391 ms 8420 KB Output is correct
48 Correct 430 ms 8516 KB Output is correct
49 Correct 402 ms 8328 KB Output is correct
50 Correct 394 ms 8392 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 451 ms 9192 KB Output is correct
53 Correct 567 ms 10060 KB Output is correct
54 Correct 797 ms 11796 KB Output is correct
55 Correct 750 ms 11952 KB Output is correct
56 Correct 571 ms 10412 KB Output is correct
57 Correct 759 ms 12008 KB Output is correct
58 Correct 779 ms 11752 KB Output is correct
59 Correct 744 ms 11820 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 748 ms 11856 KB Output is correct
62 Correct 653 ms 10872 KB Output is correct
63 Correct 661 ms 11036 KB Output is correct
64 Correct 613 ms 10892 KB Output is correct
65 Correct 610 ms 10180 KB Output is correct
66 Correct 598 ms 10060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 2 ms 724 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 7 ms 1236 KB Output is correct
11 Correct 7 ms 1252 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 7 ms 1236 KB Output is correct
15 Correct 6 ms 1236 KB Output is correct
16 Correct 7 ms 1236 KB Output is correct
17 Correct 4 ms 980 KB Output is correct
18 Correct 5 ms 1048 KB Output is correct
19 Correct 6 ms 1232 KB Output is correct
20 Correct 8 ms 1364 KB Output is correct
21 Correct 30 ms 2388 KB Output is correct
22 Correct 38 ms 2732 KB Output is correct
23 Correct 17 ms 2004 KB Output is correct
24 Correct 56 ms 3288 KB Output is correct
25 Correct 57 ms 3372 KB Output is correct
26 Correct 70 ms 3452 KB Output is correct
27 Correct 67 ms 3532 KB Output is correct
28 Correct 64 ms 3516 KB Output is correct
29 Correct 67 ms 3560 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 76 ms 3456 KB Output is correct
32 Correct 68 ms 3548 KB Output is correct
33 Correct 74 ms 3440 KB Output is correct
34 Correct 62 ms 3468 KB Output is correct
35 Correct 72 ms 3464 KB Output is correct
36 Correct 69 ms 3452 KB Output is correct
37 Correct 255 ms 6800 KB Output is correct
38 Correct 251 ms 6760 KB Output is correct
39 Correct 384 ms 8144 KB Output is correct
40 Correct 465 ms 8984 KB Output is correct
41 Correct 454 ms 8728 KB Output is correct
42 Correct 381 ms 8348 KB Output is correct
43 Correct 398 ms 8272 KB Output is correct
44 Correct 377 ms 8588 KB Output is correct
45 Correct 384 ms 8596 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 391 ms 8420 KB Output is correct
48 Correct 430 ms 8516 KB Output is correct
49 Correct 402 ms 8328 KB Output is correct
50 Correct 394 ms 8392 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 451 ms 9192 KB Output is correct
53 Correct 567 ms 10060 KB Output is correct
54 Correct 797 ms 11796 KB Output is correct
55 Correct 750 ms 11952 KB Output is correct
56 Correct 571 ms 10412 KB Output is correct
57 Correct 759 ms 12008 KB Output is correct
58 Correct 779 ms 11752 KB Output is correct
59 Correct 744 ms 11820 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 748 ms 11856 KB Output is correct
62 Correct 653 ms 10872 KB Output is correct
63 Correct 661 ms 11036 KB Output is correct
64 Correct 613 ms 10892 KB Output is correct
65 Correct 610 ms 10180 KB Output is correct
66 Correct 598 ms 10060 KB Output is correct
67 Execution timed out 1020 ms 13388 KB Time limit exceeded
68 Halted 0 ms 0 KB -