# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
246434 |
2020-07-09T09:46:06 Z |
acm |
Bootfall (IZhO17_bootfall) |
C++17 |
|
1000 ms |
12912 KB |
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <ext/rope>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <string>
#include <bits/functexcept.h>
#include <iosfwd>
#include <bits/cxxabi_forced.h>
#include <bits/functional_hash.h>
#pragma push_macro("__SIZEOF_LONG__")
#pragma push_macro("__cplusplus")
#define __SIZEOF_LONG__ __SIZEOF_LONG_LONG__
#define unsigned unsigned long
#define __cplusplus 201102L
#define __builtin_popcountl __builtin_popcountll
#define __builtin_ctzl __builtin_ctzll
#include <bitset>
#pragma pop_macro("__cplusplus")
#pragma pop_macro("__SIZEOF_LONG__")
#undef unsigned
#undef __builtin_popcountl
#undef __builtin_ctzl
#define file ""
#define all(x) x.begin(), x.end()
#define sc second
#define fr first
#define pb push_back
#define mp make_pair
#define pss pair<line*, line*>
using namespace std;
using namespace __gnu_cxx;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const ll inf = 1e18;
const int MOD = 1e9 + 7;
const int dx[] = {-1, +1, -2, +2, -2, +2, -1, +1};
const int dy[] = {-2, -2, -1, -1, +1, +1, +2, +2};
int const N = 250001;
int const M = 2e6;
bitset<N> dp[505];
signed main() {
#ifdef Mask
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
cin >> n;
int sum = 0;
int a[n + 1];
for (int i = 1; i <= n; i++)
cin >> a[i], sum += a[i];
for (int del = 0; del <= n; del++) {
dp[del][0] = 1;
for (int i = 0; i < n; i++) {
if (i + 1 == del)
continue;
dp[del] |= (dp[del] << a[i + 1]);
}
}
vector<int> ans;
for (int k = 1; k <= 250000; k++) {
bool ok = true;
for (int del = 0; del <= n; del++) {
int all = sum + k;
if (del == 0) all -= k;
else all -= a[del];
if (all % 2 == 1) {
ok = false;
break;
}
int need = all / 2;
if (need > N) {
ok = false;
break;
}
if (dp[del][need] == 0) {
ok = false;
break;
}
}
if (ok == true)
ans.pb(k);
}
cout << ans.size() << endl;
for (int to : ans)
cout << to << " ";
return 0;
}
Compilation message
bootfall.cpp:16:0: warning: "__SIZEOF_LONG__" redefined
#define __SIZEOF_LONG__ __SIZEOF_LONG_LONG__
<built-in>: note: this is the location of the previous definition
bootfall.cpp:18:0: warning: "__cplusplus" redefined
#define __cplusplus 201102L
<built-in>: note: this is the location of the previous definition
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
512 KB |
Output is correct |
2 |
Correct |
6 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
6 ms |
512 KB |
Output is correct |
5 |
Correct |
7 ms |
768 KB |
Output is correct |
6 |
Correct |
6 ms |
640 KB |
Output is correct |
7 |
Correct |
6 ms |
640 KB |
Output is correct |
8 |
Correct |
7 ms |
768 KB |
Output is correct |
9 |
Correct |
6 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
512 KB |
Output is correct |
2 |
Correct |
6 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
6 ms |
512 KB |
Output is correct |
5 |
Correct |
7 ms |
768 KB |
Output is correct |
6 |
Correct |
6 ms |
640 KB |
Output is correct |
7 |
Correct |
6 ms |
640 KB |
Output is correct |
8 |
Correct |
7 ms |
768 KB |
Output is correct |
9 |
Correct |
6 ms |
768 KB |
Output is correct |
10 |
Correct |
12 ms |
1280 KB |
Output is correct |
11 |
Correct |
13 ms |
1408 KB |
Output is correct |
12 |
Correct |
13 ms |
1408 KB |
Output is correct |
13 |
Correct |
10 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
1280 KB |
Output is correct |
15 |
Correct |
11 ms |
1280 KB |
Output is correct |
16 |
Correct |
12 ms |
1280 KB |
Output is correct |
17 |
Correct |
8 ms |
1024 KB |
Output is correct |
18 |
Correct |
10 ms |
1152 KB |
Output is correct |
19 |
Correct |
10 ms |
1280 KB |
Output is correct |
20 |
Correct |
12 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
512 KB |
Output is correct |
2 |
Correct |
6 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
6 ms |
512 KB |
Output is correct |
5 |
Correct |
7 ms |
768 KB |
Output is correct |
6 |
Correct |
6 ms |
640 KB |
Output is correct |
7 |
Correct |
6 ms |
640 KB |
Output is correct |
8 |
Correct |
7 ms |
768 KB |
Output is correct |
9 |
Correct |
6 ms |
768 KB |
Output is correct |
10 |
Correct |
12 ms |
1280 KB |
Output is correct |
11 |
Correct |
13 ms |
1408 KB |
Output is correct |
12 |
Correct |
13 ms |
1408 KB |
Output is correct |
13 |
Correct |
10 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
1280 KB |
Output is correct |
15 |
Correct |
11 ms |
1280 KB |
Output is correct |
16 |
Correct |
12 ms |
1280 KB |
Output is correct |
17 |
Correct |
8 ms |
1024 KB |
Output is correct |
18 |
Correct |
10 ms |
1152 KB |
Output is correct |
19 |
Correct |
10 ms |
1280 KB |
Output is correct |
20 |
Correct |
12 ms |
1280 KB |
Output is correct |
21 |
Correct |
35 ms |
2424 KB |
Output is correct |
22 |
Correct |
48 ms |
2824 KB |
Output is correct |
23 |
Correct |
23 ms |
1920 KB |
Output is correct |
24 |
Correct |
64 ms |
3320 KB |
Output is correct |
25 |
Correct |
66 ms |
3320 KB |
Output is correct |
26 |
Correct |
75 ms |
3576 KB |
Output is correct |
27 |
Correct |
72 ms |
3448 KB |
Output is correct |
28 |
Correct |
74 ms |
3572 KB |
Output is correct |
29 |
Correct |
75 ms |
3448 KB |
Output is correct |
30 |
Correct |
73 ms |
3424 KB |
Output is correct |
31 |
Correct |
74 ms |
3576 KB |
Output is correct |
32 |
Correct |
74 ms |
3580 KB |
Output is correct |
33 |
Correct |
81 ms |
3448 KB |
Output is correct |
34 |
Correct |
74 ms |
3448 KB |
Output is correct |
35 |
Correct |
73 ms |
3576 KB |
Output is correct |
36 |
Correct |
75 ms |
3480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
512 KB |
Output is correct |
2 |
Correct |
6 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
6 ms |
512 KB |
Output is correct |
5 |
Correct |
7 ms |
768 KB |
Output is correct |
6 |
Correct |
6 ms |
640 KB |
Output is correct |
7 |
Correct |
6 ms |
640 KB |
Output is correct |
8 |
Correct |
7 ms |
768 KB |
Output is correct |
9 |
Correct |
6 ms |
768 KB |
Output is correct |
10 |
Correct |
12 ms |
1280 KB |
Output is correct |
11 |
Correct |
13 ms |
1408 KB |
Output is correct |
12 |
Correct |
13 ms |
1408 KB |
Output is correct |
13 |
Correct |
10 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
1280 KB |
Output is correct |
15 |
Correct |
11 ms |
1280 KB |
Output is correct |
16 |
Correct |
12 ms |
1280 KB |
Output is correct |
17 |
Correct |
8 ms |
1024 KB |
Output is correct |
18 |
Correct |
10 ms |
1152 KB |
Output is correct |
19 |
Correct |
10 ms |
1280 KB |
Output is correct |
20 |
Correct |
12 ms |
1280 KB |
Output is correct |
21 |
Correct |
35 ms |
2424 KB |
Output is correct |
22 |
Correct |
48 ms |
2824 KB |
Output is correct |
23 |
Correct |
23 ms |
1920 KB |
Output is correct |
24 |
Correct |
64 ms |
3320 KB |
Output is correct |
25 |
Correct |
66 ms |
3320 KB |
Output is correct |
26 |
Correct |
75 ms |
3576 KB |
Output is correct |
27 |
Correct |
72 ms |
3448 KB |
Output is correct |
28 |
Correct |
74 ms |
3572 KB |
Output is correct |
29 |
Correct |
75 ms |
3448 KB |
Output is correct |
30 |
Correct |
73 ms |
3424 KB |
Output is correct |
31 |
Correct |
74 ms |
3576 KB |
Output is correct |
32 |
Correct |
74 ms |
3580 KB |
Output is correct |
33 |
Correct |
81 ms |
3448 KB |
Output is correct |
34 |
Correct |
74 ms |
3448 KB |
Output is correct |
35 |
Correct |
73 ms |
3576 KB |
Output is correct |
36 |
Correct |
75 ms |
3480 KB |
Output is correct |
37 |
Correct |
269 ms |
6648 KB |
Output is correct |
38 |
Correct |
271 ms |
6684 KB |
Output is correct |
39 |
Correct |
400 ms |
8056 KB |
Output is correct |
40 |
Correct |
505 ms |
8952 KB |
Output is correct |
41 |
Correct |
484 ms |
8748 KB |
Output is correct |
42 |
Correct |
428 ms |
8544 KB |
Output is correct |
43 |
Correct |
410 ms |
8260 KB |
Output is correct |
44 |
Correct |
413 ms |
8440 KB |
Output is correct |
45 |
Correct |
431 ms |
8516 KB |
Output is correct |
46 |
Correct |
480 ms |
8696 KB |
Output is correct |
47 |
Correct |
433 ms |
8284 KB |
Output is correct |
48 |
Correct |
443 ms |
8572 KB |
Output is correct |
49 |
Correct |
408 ms |
8184 KB |
Output is correct |
50 |
Correct |
421 ms |
8432 KB |
Output is correct |
51 |
Correct |
413 ms |
8100 KB |
Output is correct |
52 |
Correct |
537 ms |
9236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
512 KB |
Output is correct |
2 |
Correct |
6 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
6 ms |
512 KB |
Output is correct |
5 |
Correct |
7 ms |
768 KB |
Output is correct |
6 |
Correct |
6 ms |
640 KB |
Output is correct |
7 |
Correct |
6 ms |
640 KB |
Output is correct |
8 |
Correct |
7 ms |
768 KB |
Output is correct |
9 |
Correct |
6 ms |
768 KB |
Output is correct |
10 |
Correct |
12 ms |
1280 KB |
Output is correct |
11 |
Correct |
13 ms |
1408 KB |
Output is correct |
12 |
Correct |
13 ms |
1408 KB |
Output is correct |
13 |
Correct |
10 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
1280 KB |
Output is correct |
15 |
Correct |
11 ms |
1280 KB |
Output is correct |
16 |
Correct |
12 ms |
1280 KB |
Output is correct |
17 |
Correct |
8 ms |
1024 KB |
Output is correct |
18 |
Correct |
10 ms |
1152 KB |
Output is correct |
19 |
Correct |
10 ms |
1280 KB |
Output is correct |
20 |
Correct |
12 ms |
1280 KB |
Output is correct |
21 |
Correct |
35 ms |
2424 KB |
Output is correct |
22 |
Correct |
48 ms |
2824 KB |
Output is correct |
23 |
Correct |
23 ms |
1920 KB |
Output is correct |
24 |
Correct |
64 ms |
3320 KB |
Output is correct |
25 |
Correct |
66 ms |
3320 KB |
Output is correct |
26 |
Correct |
75 ms |
3576 KB |
Output is correct |
27 |
Correct |
72 ms |
3448 KB |
Output is correct |
28 |
Correct |
74 ms |
3572 KB |
Output is correct |
29 |
Correct |
75 ms |
3448 KB |
Output is correct |
30 |
Correct |
73 ms |
3424 KB |
Output is correct |
31 |
Correct |
74 ms |
3576 KB |
Output is correct |
32 |
Correct |
74 ms |
3580 KB |
Output is correct |
33 |
Correct |
81 ms |
3448 KB |
Output is correct |
34 |
Correct |
74 ms |
3448 KB |
Output is correct |
35 |
Correct |
73 ms |
3576 KB |
Output is correct |
36 |
Correct |
75 ms |
3480 KB |
Output is correct |
37 |
Correct |
269 ms |
6648 KB |
Output is correct |
38 |
Correct |
271 ms |
6684 KB |
Output is correct |
39 |
Correct |
400 ms |
8056 KB |
Output is correct |
40 |
Correct |
505 ms |
8952 KB |
Output is correct |
41 |
Correct |
484 ms |
8748 KB |
Output is correct |
42 |
Correct |
428 ms |
8544 KB |
Output is correct |
43 |
Correct |
410 ms |
8260 KB |
Output is correct |
44 |
Correct |
413 ms |
8440 KB |
Output is correct |
45 |
Correct |
431 ms |
8516 KB |
Output is correct |
46 |
Correct |
480 ms |
8696 KB |
Output is correct |
47 |
Correct |
433 ms |
8284 KB |
Output is correct |
48 |
Correct |
443 ms |
8572 KB |
Output is correct |
49 |
Correct |
408 ms |
8184 KB |
Output is correct |
50 |
Correct |
421 ms |
8432 KB |
Output is correct |
51 |
Correct |
413 ms |
8100 KB |
Output is correct |
52 |
Correct |
537 ms |
9236 KB |
Output is correct |
53 |
Correct |
609 ms |
10016 KB |
Output is correct |
54 |
Correct |
820 ms |
11592 KB |
Output is correct |
55 |
Correct |
823 ms |
11824 KB |
Output is correct |
56 |
Correct |
628 ms |
10248 KB |
Output is correct |
57 |
Correct |
838 ms |
11792 KB |
Output is correct |
58 |
Correct |
827 ms |
11768 KB |
Output is correct |
59 |
Correct |
832 ms |
11768 KB |
Output is correct |
60 |
Correct |
792 ms |
11256 KB |
Output is correct |
61 |
Correct |
850 ms |
11804 KB |
Output is correct |
62 |
Correct |
718 ms |
10872 KB |
Output is correct |
63 |
Correct |
732 ms |
11000 KB |
Output is correct |
64 |
Correct |
677 ms |
10788 KB |
Output is correct |
65 |
Correct |
647 ms |
10104 KB |
Output is correct |
66 |
Correct |
640 ms |
9976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
512 KB |
Output is correct |
2 |
Correct |
6 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
6 ms |
512 KB |
Output is correct |
5 |
Correct |
7 ms |
768 KB |
Output is correct |
6 |
Correct |
6 ms |
640 KB |
Output is correct |
7 |
Correct |
6 ms |
640 KB |
Output is correct |
8 |
Correct |
7 ms |
768 KB |
Output is correct |
9 |
Correct |
6 ms |
768 KB |
Output is correct |
10 |
Correct |
12 ms |
1280 KB |
Output is correct |
11 |
Correct |
13 ms |
1408 KB |
Output is correct |
12 |
Correct |
13 ms |
1408 KB |
Output is correct |
13 |
Correct |
10 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
1280 KB |
Output is correct |
15 |
Correct |
11 ms |
1280 KB |
Output is correct |
16 |
Correct |
12 ms |
1280 KB |
Output is correct |
17 |
Correct |
8 ms |
1024 KB |
Output is correct |
18 |
Correct |
10 ms |
1152 KB |
Output is correct |
19 |
Correct |
10 ms |
1280 KB |
Output is correct |
20 |
Correct |
12 ms |
1280 KB |
Output is correct |
21 |
Correct |
35 ms |
2424 KB |
Output is correct |
22 |
Correct |
48 ms |
2824 KB |
Output is correct |
23 |
Correct |
23 ms |
1920 KB |
Output is correct |
24 |
Correct |
64 ms |
3320 KB |
Output is correct |
25 |
Correct |
66 ms |
3320 KB |
Output is correct |
26 |
Correct |
75 ms |
3576 KB |
Output is correct |
27 |
Correct |
72 ms |
3448 KB |
Output is correct |
28 |
Correct |
74 ms |
3572 KB |
Output is correct |
29 |
Correct |
75 ms |
3448 KB |
Output is correct |
30 |
Correct |
73 ms |
3424 KB |
Output is correct |
31 |
Correct |
74 ms |
3576 KB |
Output is correct |
32 |
Correct |
74 ms |
3580 KB |
Output is correct |
33 |
Correct |
81 ms |
3448 KB |
Output is correct |
34 |
Correct |
74 ms |
3448 KB |
Output is correct |
35 |
Correct |
73 ms |
3576 KB |
Output is correct |
36 |
Correct |
75 ms |
3480 KB |
Output is correct |
37 |
Correct |
269 ms |
6648 KB |
Output is correct |
38 |
Correct |
271 ms |
6684 KB |
Output is correct |
39 |
Correct |
400 ms |
8056 KB |
Output is correct |
40 |
Correct |
505 ms |
8952 KB |
Output is correct |
41 |
Correct |
484 ms |
8748 KB |
Output is correct |
42 |
Correct |
428 ms |
8544 KB |
Output is correct |
43 |
Correct |
410 ms |
8260 KB |
Output is correct |
44 |
Correct |
413 ms |
8440 KB |
Output is correct |
45 |
Correct |
431 ms |
8516 KB |
Output is correct |
46 |
Correct |
480 ms |
8696 KB |
Output is correct |
47 |
Correct |
433 ms |
8284 KB |
Output is correct |
48 |
Correct |
443 ms |
8572 KB |
Output is correct |
49 |
Correct |
408 ms |
8184 KB |
Output is correct |
50 |
Correct |
421 ms |
8432 KB |
Output is correct |
51 |
Correct |
413 ms |
8100 KB |
Output is correct |
52 |
Correct |
537 ms |
9236 KB |
Output is correct |
53 |
Correct |
609 ms |
10016 KB |
Output is correct |
54 |
Correct |
820 ms |
11592 KB |
Output is correct |
55 |
Correct |
823 ms |
11824 KB |
Output is correct |
56 |
Correct |
628 ms |
10248 KB |
Output is correct |
57 |
Correct |
838 ms |
11792 KB |
Output is correct |
58 |
Correct |
827 ms |
11768 KB |
Output is correct |
59 |
Correct |
832 ms |
11768 KB |
Output is correct |
60 |
Correct |
792 ms |
11256 KB |
Output is correct |
61 |
Correct |
850 ms |
11804 KB |
Output is correct |
62 |
Correct |
718 ms |
10872 KB |
Output is correct |
63 |
Correct |
732 ms |
11000 KB |
Output is correct |
64 |
Correct |
677 ms |
10788 KB |
Output is correct |
65 |
Correct |
647 ms |
10104 KB |
Output is correct |
66 |
Correct |
640 ms |
9976 KB |
Output is correct |
67 |
Execution timed out |
1081 ms |
12912 KB |
Time limit exceeded |
68 |
Halted |
0 ms |
0 KB |
- |