# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
598438 | 2022-07-18T11:20:27 Z | SuffixAutomata | Bootfall (IZhO17_bootfall) | C++17 | 556 ms | 3708 KB |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int dp[500 * 500 + 1], dp2[500 * 500 + 1]; bool ok[500 * 500 + 1]; int main() { int n; cin >> n; vector<int> ar(n); int sm = 0; dp[0] = 1; for (int i = 0; i < n; i++) { cin >> ar[i]; for (int j = sm; j >= 0; j--) dp[j + ar[i]] = (dp[j + ar[i]] + dp[j]) % MOD; sm += ar[i]; } auto x = [&](int i) { if (i < 0 || i % 2 || i / 2 > sm) return 0; return dp2[i / 2]; }; vector<int> ans; if (sm % 2 == 0 && dp[sm / 2]) { for (int v = 0; v <= 500 * 500; v++) ok[v] = 1; for (int i : ar) { memcpy(dp2, dp, sizeof dp2); for (int j = 0; j <= sm - i; j++) dp2[j + i] = (dp2[j + i] + MOD - dp2[j]) % MOD; for (int v = 0; v <= 500 * 500; v++) ok[v] = ok[v] && ((x(sm + v - i) + x(sm - v - i)) % MOD); } for (int v = 0; v <= 500 * 500; v++) if (ok[v]) ans.push_back(v); } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) cout << ans[i] << " \n"[i == ans.size() - 1]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1492 KB | Output is correct |
2 | Correct | 3 ms | 1492 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 3 ms | 1540 KB | Output is correct |
5 | Correct | 4 ms | 1492 KB | Output is correct |
6 | Correct | 4 ms | 1460 KB | Output is correct |
7 | Correct | 3 ms | 1492 KB | Output is correct |
8 | Correct | 6 ms | 1492 KB | Output is correct |
9 | Correct | 5 ms | 1492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1492 KB | Output is correct |
2 | Correct | 3 ms | 1492 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 3 ms | 1540 KB | Output is correct |
5 | Correct | 4 ms | 1492 KB | Output is correct |
6 | Correct | 4 ms | 1460 KB | Output is correct |
7 | Correct | 3 ms | 1492 KB | Output is correct |
8 | Correct | 6 ms | 1492 KB | Output is correct |
9 | Correct | 5 ms | 1492 KB | Output is correct |
10 | Correct | 10 ms | 1492 KB | Output is correct |
11 | Correct | 9 ms | 1440 KB | Output is correct |
12 | Correct | 8 ms | 1492 KB | Output is correct |
13 | Correct | 7 ms | 1492 KB | Output is correct |
14 | Correct | 9 ms | 1492 KB | Output is correct |
15 | Correct | 10 ms | 1492 KB | Output is correct |
16 | Correct | 10 ms | 1532 KB | Output is correct |
17 | Correct | 8 ms | 1528 KB | Output is correct |
18 | Correct | 8 ms | 1492 KB | Output is correct |
19 | Correct | 8 ms | 1492 KB | Output is correct |
20 | Correct | 9 ms | 1464 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1492 KB | Output is correct |
2 | Correct | 3 ms | 1492 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 3 ms | 1540 KB | Output is correct |
5 | Correct | 4 ms | 1492 KB | Output is correct |
6 | Correct | 4 ms | 1460 KB | Output is correct |
7 | Correct | 3 ms | 1492 KB | Output is correct |
8 | Correct | 6 ms | 1492 KB | Output is correct |
9 | Correct | 5 ms | 1492 KB | Output is correct |
10 | Correct | 10 ms | 1492 KB | Output is correct |
11 | Correct | 9 ms | 1440 KB | Output is correct |
12 | Correct | 8 ms | 1492 KB | Output is correct |
13 | Correct | 7 ms | 1492 KB | Output is correct |
14 | Correct | 9 ms | 1492 KB | Output is correct |
15 | Correct | 10 ms | 1492 KB | Output is correct |
16 | Correct | 10 ms | 1532 KB | Output is correct |
17 | Correct | 8 ms | 1528 KB | Output is correct |
18 | Correct | 8 ms | 1492 KB | Output is correct |
19 | Correct | 8 ms | 1492 KB | Output is correct |
20 | Correct | 9 ms | 1464 KB | Output is correct |
21 | Correct | 16 ms | 1560 KB | Output is correct |
22 | Correct | 18 ms | 1532 KB | Output is correct |
23 | Correct | 12 ms | 1544 KB | Output is correct |
24 | Correct | 23 ms | 1492 KB | Output is correct |
25 | Correct | 24 ms | 1556 KB | Output is correct |
26 | Correct | 26 ms | 1560 KB | Output is correct |
27 | Correct | 25 ms | 1564 KB | Output is correct |
28 | Correct | 35 ms | 1548 KB | Output is correct |
29 | Correct | 38 ms | 1556 KB | Output is correct |
30 | Correct | 30 ms | 1492 KB | Output is correct |
31 | Correct | 26 ms | 1492 KB | Output is correct |
32 | Correct | 24 ms | 1536 KB | Output is correct |
33 | Correct | 26 ms | 1556 KB | Output is correct |
34 | Correct | 25 ms | 1568 KB | Output is correct |
35 | Correct | 25 ms | 1492 KB | Output is correct |
36 | Correct | 24 ms | 1544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1492 KB | Output is correct |
2 | Correct | 3 ms | 1492 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 3 ms | 1540 KB | Output is correct |
5 | Correct | 4 ms | 1492 KB | Output is correct |
6 | Correct | 4 ms | 1460 KB | Output is correct |
7 | Correct | 3 ms | 1492 KB | Output is correct |
8 | Correct | 6 ms | 1492 KB | Output is correct |
9 | Correct | 5 ms | 1492 KB | Output is correct |
10 | Correct | 10 ms | 1492 KB | Output is correct |
11 | Correct | 9 ms | 1440 KB | Output is correct |
12 | Correct | 8 ms | 1492 KB | Output is correct |
13 | Correct | 7 ms | 1492 KB | Output is correct |
14 | Correct | 9 ms | 1492 KB | Output is correct |
15 | Correct | 10 ms | 1492 KB | Output is correct |
16 | Correct | 10 ms | 1532 KB | Output is correct |
17 | Correct | 8 ms | 1528 KB | Output is correct |
18 | Correct | 8 ms | 1492 KB | Output is correct |
19 | Correct | 8 ms | 1492 KB | Output is correct |
20 | Correct | 9 ms | 1464 KB | Output is correct |
21 | Correct | 16 ms | 1560 KB | Output is correct |
22 | Correct | 18 ms | 1532 KB | Output is correct |
23 | Correct | 12 ms | 1544 KB | Output is correct |
24 | Correct | 23 ms | 1492 KB | Output is correct |
25 | Correct | 24 ms | 1556 KB | Output is correct |
26 | Correct | 26 ms | 1560 KB | Output is correct |
27 | Correct | 25 ms | 1564 KB | Output is correct |
28 | Correct | 35 ms | 1548 KB | Output is correct |
29 | Correct | 38 ms | 1556 KB | Output is correct |
30 | Correct | 30 ms | 1492 KB | Output is correct |
31 | Correct | 26 ms | 1492 KB | Output is correct |
32 | Correct | 24 ms | 1536 KB | Output is correct |
33 | Correct | 26 ms | 1556 KB | Output is correct |
34 | Correct | 25 ms | 1568 KB | Output is correct |
35 | Correct | 25 ms | 1492 KB | Output is correct |
36 | Correct | 24 ms | 1544 KB | Output is correct |
37 | Correct | 68 ms | 1712 KB | Output is correct |
38 | Correct | 57 ms | 1716 KB | Output is correct |
39 | Correct | 100 ms | 1732 KB | Output is correct |
40 | Correct | 94 ms | 1764 KB | Output is correct |
41 | Correct | 123 ms | 1792 KB | Output is correct |
42 | Correct | 91 ms | 1760 KB | Output is correct |
43 | Correct | 101 ms | 2032 KB | Output is correct |
44 | Correct | 107 ms | 2120 KB | Output is correct |
45 | Correct | 109 ms | 2124 KB | Output is correct |
46 | Correct | 81 ms | 1636 KB | Output is correct |
47 | Correct | 88 ms | 1780 KB | Output is correct |
48 | Correct | 111 ms | 2012 KB | Output is correct |
49 | Correct | 106 ms | 1812 KB | Output is correct |
50 | Correct | 87 ms | 1764 KB | Output is correct |
51 | Correct | 15 ms | 424 KB | Output is correct |
52 | Correct | 131 ms | 2208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1492 KB | Output is correct |
2 | Correct | 3 ms | 1492 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 3 ms | 1540 KB | Output is correct |
5 | Correct | 4 ms | 1492 KB | Output is correct |
6 | Correct | 4 ms | 1460 KB | Output is correct |
7 | Correct | 3 ms | 1492 KB | Output is correct |
8 | Correct | 6 ms | 1492 KB | Output is correct |
9 | Correct | 5 ms | 1492 KB | Output is correct |
10 | Correct | 10 ms | 1492 KB | Output is correct |
11 | Correct | 9 ms | 1440 KB | Output is correct |
12 | Correct | 8 ms | 1492 KB | Output is correct |
13 | Correct | 7 ms | 1492 KB | Output is correct |
14 | Correct | 9 ms | 1492 KB | Output is correct |
15 | Correct | 10 ms | 1492 KB | Output is correct |
16 | Correct | 10 ms | 1532 KB | Output is correct |
17 | Correct | 8 ms | 1528 KB | Output is correct |
18 | Correct | 8 ms | 1492 KB | Output is correct |
19 | Correct | 8 ms | 1492 KB | Output is correct |
20 | Correct | 9 ms | 1464 KB | Output is correct |
21 | Correct | 16 ms | 1560 KB | Output is correct |
22 | Correct | 18 ms | 1532 KB | Output is correct |
23 | Correct | 12 ms | 1544 KB | Output is correct |
24 | Correct | 23 ms | 1492 KB | Output is correct |
25 | Correct | 24 ms | 1556 KB | Output is correct |
26 | Correct | 26 ms | 1560 KB | Output is correct |
27 | Correct | 25 ms | 1564 KB | Output is correct |
28 | Correct | 35 ms | 1548 KB | Output is correct |
29 | Correct | 38 ms | 1556 KB | Output is correct |
30 | Correct | 30 ms | 1492 KB | Output is correct |
31 | Correct | 26 ms | 1492 KB | Output is correct |
32 | Correct | 24 ms | 1536 KB | Output is correct |
33 | Correct | 26 ms | 1556 KB | Output is correct |
34 | Correct | 25 ms | 1568 KB | Output is correct |
35 | Correct | 25 ms | 1492 KB | Output is correct |
36 | Correct | 24 ms | 1544 KB | Output is correct |
37 | Correct | 68 ms | 1712 KB | Output is correct |
38 | Correct | 57 ms | 1716 KB | Output is correct |
39 | Correct | 100 ms | 1732 KB | Output is correct |
40 | Correct | 94 ms | 1764 KB | Output is correct |
41 | Correct | 123 ms | 1792 KB | Output is correct |
42 | Correct | 91 ms | 1760 KB | Output is correct |
43 | Correct | 101 ms | 2032 KB | Output is correct |
44 | Correct | 107 ms | 2120 KB | Output is correct |
45 | Correct | 109 ms | 2124 KB | Output is correct |
46 | Correct | 81 ms | 1636 KB | Output is correct |
47 | Correct | 88 ms | 1780 KB | Output is correct |
48 | Correct | 111 ms | 2012 KB | Output is correct |
49 | Correct | 106 ms | 1812 KB | Output is correct |
50 | Correct | 87 ms | 1764 KB | Output is correct |
51 | Correct | 15 ms | 424 KB | Output is correct |
52 | Correct | 131 ms | 2208 KB | Output is correct |
53 | Correct | 134 ms | 1948 KB | Output is correct |
54 | Correct | 148 ms | 2112 KB | Output is correct |
55 | Correct | 218 ms | 2476 KB | Output is correct |
56 | Correct | 130 ms | 2136 KB | Output is correct |
57 | Correct | 228 ms | 2608 KB | Output is correct |
58 | Correct | 158 ms | 2144 KB | Output is correct |
59 | Correct | 188 ms | 2376 KB | Output is correct |
60 | Correct | 35 ms | 476 KB | Output is correct |
61 | Correct | 189 ms | 2376 KB | Output is correct |
62 | Correct | 185 ms | 2388 KB | Output is correct |
63 | Correct | 207 ms | 2532 KB | Output is correct |
64 | Correct | 190 ms | 2420 KB | Output is correct |
65 | Correct | 118 ms | 1604 KB | Output is correct |
66 | Correct | 122 ms | 1712 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1492 KB | Output is correct |
2 | Correct | 3 ms | 1492 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 3 ms | 1540 KB | Output is correct |
5 | Correct | 4 ms | 1492 KB | Output is correct |
6 | Correct | 4 ms | 1460 KB | Output is correct |
7 | Correct | 3 ms | 1492 KB | Output is correct |
8 | Correct | 6 ms | 1492 KB | Output is correct |
9 | Correct | 5 ms | 1492 KB | Output is correct |
10 | Correct | 10 ms | 1492 KB | Output is correct |
11 | Correct | 9 ms | 1440 KB | Output is correct |
12 | Correct | 8 ms | 1492 KB | Output is correct |
13 | Correct | 7 ms | 1492 KB | Output is correct |
14 | Correct | 9 ms | 1492 KB | Output is correct |
15 | Correct | 10 ms | 1492 KB | Output is correct |
16 | Correct | 10 ms | 1532 KB | Output is correct |
17 | Correct | 8 ms | 1528 KB | Output is correct |
18 | Correct | 8 ms | 1492 KB | Output is correct |
19 | Correct | 8 ms | 1492 KB | Output is correct |
20 | Correct | 9 ms | 1464 KB | Output is correct |
21 | Correct | 16 ms | 1560 KB | Output is correct |
22 | Correct | 18 ms | 1532 KB | Output is correct |
23 | Correct | 12 ms | 1544 KB | Output is correct |
24 | Correct | 23 ms | 1492 KB | Output is correct |
25 | Correct | 24 ms | 1556 KB | Output is correct |
26 | Correct | 26 ms | 1560 KB | Output is correct |
27 | Correct | 25 ms | 1564 KB | Output is correct |
28 | Correct | 35 ms | 1548 KB | Output is correct |
29 | Correct | 38 ms | 1556 KB | Output is correct |
30 | Correct | 30 ms | 1492 KB | Output is correct |
31 | Correct | 26 ms | 1492 KB | Output is correct |
32 | Correct | 24 ms | 1536 KB | Output is correct |
33 | Correct | 26 ms | 1556 KB | Output is correct |
34 | Correct | 25 ms | 1568 KB | Output is correct |
35 | Correct | 25 ms | 1492 KB | Output is correct |
36 | Correct | 24 ms | 1544 KB | Output is correct |
37 | Correct | 68 ms | 1712 KB | Output is correct |
38 | Correct | 57 ms | 1716 KB | Output is correct |
39 | Correct | 100 ms | 1732 KB | Output is correct |
40 | Correct | 94 ms | 1764 KB | Output is correct |
41 | Correct | 123 ms | 1792 KB | Output is correct |
42 | Correct | 91 ms | 1760 KB | Output is correct |
43 | Correct | 101 ms | 2032 KB | Output is correct |
44 | Correct | 107 ms | 2120 KB | Output is correct |
45 | Correct | 109 ms | 2124 KB | Output is correct |
46 | Correct | 81 ms | 1636 KB | Output is correct |
47 | Correct | 88 ms | 1780 KB | Output is correct |
48 | Correct | 111 ms | 2012 KB | Output is correct |
49 | Correct | 106 ms | 1812 KB | Output is correct |
50 | Correct | 87 ms | 1764 KB | Output is correct |
51 | Correct | 15 ms | 424 KB | Output is correct |
52 | Correct | 131 ms | 2208 KB | Output is correct |
53 | Correct | 134 ms | 1948 KB | Output is correct |
54 | Correct | 148 ms | 2112 KB | Output is correct |
55 | Correct | 218 ms | 2476 KB | Output is correct |
56 | Correct | 130 ms | 2136 KB | Output is correct |
57 | Correct | 228 ms | 2608 KB | Output is correct |
58 | Correct | 158 ms | 2144 KB | Output is correct |
59 | Correct | 188 ms | 2376 KB | Output is correct |
60 | Correct | 35 ms | 476 KB | Output is correct |
61 | Correct | 189 ms | 2376 KB | Output is correct |
62 | Correct | 185 ms | 2388 KB | Output is correct |
63 | Correct | 207 ms | 2532 KB | Output is correct |
64 | Correct | 190 ms | 2420 KB | Output is correct |
65 | Correct | 118 ms | 1604 KB | Output is correct |
66 | Correct | 122 ms | 1712 KB | Output is correct |
67 | Correct | 193 ms | 2332 KB | Output is correct |
68 | Correct | 102 ms | 716 KB | Output is correct |
69 | Correct | 527 ms | 3452 KB | Output is correct |
70 | Correct | 354 ms | 2772 KB | Output is correct |
71 | Correct | 361 ms | 2764 KB | Output is correct |
72 | Correct | 307 ms | 1996 KB | Output is correct |
73 | Correct | 284 ms | 1960 KB | Output is correct |
74 | Correct | 544 ms | 3616 KB | Output is correct |
75 | Correct | 439 ms | 3224 KB | Output is correct |
76 | Correct | 551 ms | 3692 KB | Output is correct |
77 | Correct | 556 ms | 3708 KB | Output is correct |