# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
50799 | 2018-06-13T10:50:42 Z | waynetuinfor | Bali Sculptures (APIO15_sculpture) | C++17 | 477 ms | 16932 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 2000 + 5; long long s[maxn], y[maxn]; int dp[maxn][maxn], qu[maxn], dt[maxn]; vector<int> gr[maxn]; int main() { int n, a, b; scanf("%d %d %d", &n, &a, &b); for (int i = 1; i <= n; ++i) { scanf("%lld", &y[i]); s[i] = s[i - 1] + y[i]; } if (a == 1) { long long ans = 0, mask = 0; for (int t = 44; t >= 0; --t) { for (int i = 0; i < maxn; ++i) gr[i].clear(); for (int i = 1; i <= n; ++i) { for (int j = 0; j < i; ++j) { if (mask & (s[i] - s[j])) continue; int bit = (s[i] - s[j]) >> t & 1; if (bit == 0) gr[j].push_back(i); } } memset(dt, -1, sizeof(dt)); dt[0] = 0; int l = 0, r = 0; qu[r++] = 0; while (l < r) { int x = qu[l++]; if (x == n) break; for (int u : gr[x]) if (dt[u] == -1) { dt[u] = dt[x] + 1; qu[r++] = u; } } if (dt[n] != -1 && dt[n] <= b) mask ^= (1ll << t); else ans ^= (1ll << t); } printf("%lld\n", ans); return 0; } long long ans = 0, mask = 0; for (int t = 44; t >= 0; --t) { for (int i = 0; i < maxn; ++i) for (int j = 0; j < maxn; ++j) dp[i][j] = maxn; dp[0][0] = 0; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { for (int k = 0; k < j; ++k) { if (mask & (s[j] - s[k])) continue; int bit = (s[j] - s[k]) >> t & 1; dp[j][i] = min(dp[j][i], dp[k][i - 1] | bit); } } } bool f = false; for (int i = a; i <= b; ++i) f |= dp[n][i] == 0; if (f) mask ^= (1ll << t); else ans ^= (1ll << t); } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 572 KB | Output is correct |
3 | Correct | 2 ms | 572 KB | Output is correct |
4 | Correct | 2 ms | 640 KB | Output is correct |
5 | Correct | 2 ms | 640 KB | Output is correct |
6 | Correct | 2 ms | 640 KB | Output is correct |
7 | Correct | 2 ms | 640 KB | Output is correct |
8 | Correct | 2 ms | 680 KB | Output is correct |
9 | Correct | 2 ms | 680 KB | Output is correct |
10 | Correct | 2 ms | 680 KB | Output is correct |
11 | Correct | 2 ms | 680 KB | Output is correct |
12 | Correct | 2 ms | 680 KB | Output is correct |
13 | Correct | 2 ms | 684 KB | Output is correct |
14 | Correct | 128 ms | 16432 KB | Output is correct |
15 | Correct | 126 ms | 16436 KB | Output is correct |
16 | Correct | 139 ms | 16472 KB | Output is correct |
17 | Correct | 130 ms | 16572 KB | Output is correct |
18 | Correct | 127 ms | 16572 KB | Output is correct |
19 | Correct | 127 ms | 16580 KB | Output is correct |
20 | Correct | 136 ms | 16580 KB | Output is correct |
21 | Correct | 128 ms | 16580 KB | Output is correct |
22 | Correct | 128 ms | 16580 KB | Output is correct |
23 | Correct | 128 ms | 16600 KB | Output is correct |
24 | Correct | 162 ms | 16604 KB | Output is correct |
25 | Correct | 134 ms | 16604 KB | Output is correct |
26 | Correct | 127 ms | 16604 KB | Output is correct |
27 | Correct | 2 ms | 16604 KB | Output is correct |
28 | Correct | 2 ms | 16604 KB | Output is correct |
29 | Correct | 2 ms | 16604 KB | Output is correct |
30 | Correct | 2 ms | 16604 KB | Output is correct |
31 | Correct | 2 ms | 16604 KB | Output is correct |
32 | Correct | 2 ms | 16604 KB | Output is correct |
33 | Correct | 2 ms | 16604 KB | Output is correct |
34 | Correct | 2 ms | 16604 KB | Output is correct |
35 | Correct | 2 ms | 16604 KB | Output is correct |
36 | Correct | 2 ms | 16604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 16604 KB | Output is correct |
2 | Correct | 2 ms | 16604 KB | Output is correct |
3 | Correct | 2 ms | 16604 KB | Output is correct |
4 | Correct | 2 ms | 16604 KB | Output is correct |
5 | Correct | 2 ms | 16604 KB | Output is correct |
6 | Correct | 3 ms | 16604 KB | Output is correct |
7 | Correct | 2 ms | 16604 KB | Output is correct |
8 | Correct | 2 ms | 16604 KB | Output is correct |
9 | Correct | 2 ms | 16604 KB | Output is correct |
10 | Correct | 2 ms | 16604 KB | Output is correct |
11 | Correct | 2 ms | 16604 KB | Output is correct |
12 | Correct | 2 ms | 16604 KB | Output is correct |
13 | Correct | 2 ms | 16604 KB | Output is correct |
14 | Correct | 127 ms | 16716 KB | Output is correct |
15 | Correct | 128 ms | 16716 KB | Output is correct |
16 | Correct | 126 ms | 16716 KB | Output is correct |
17 | Correct | 128 ms | 16716 KB | Output is correct |
18 | Correct | 130 ms | 16716 KB | Output is correct |
19 | Correct | 141 ms | 16716 KB | Output is correct |
20 | Correct | 129 ms | 16716 KB | Output is correct |
21 | Correct | 142 ms | 16716 KB | Output is correct |
22 | Correct | 127 ms | 16716 KB | Output is correct |
23 | Correct | 155 ms | 16716 KB | Output is correct |
24 | Correct | 139 ms | 16716 KB | Output is correct |
25 | Correct | 167 ms | 16716 KB | Output is correct |
26 | Correct | 180 ms | 16716 KB | Output is correct |
27 | Correct | 2 ms | 16716 KB | Output is correct |
28 | Correct | 2 ms | 16716 KB | Output is correct |
29 | Correct | 2 ms | 16716 KB | Output is correct |
30 | Correct | 2 ms | 16716 KB | Output is correct |
31 | Correct | 2 ms | 16716 KB | Output is correct |
32 | Correct | 3 ms | 16716 KB | Output is correct |
33 | Correct | 2 ms | 16716 KB | Output is correct |
34 | Correct | 2 ms | 16716 KB | Output is correct |
35 | Correct | 2 ms | 16716 KB | Output is correct |
36 | Correct | 2 ms | 16716 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 16716 KB | Output is correct |
2 | Correct | 2 ms | 16716 KB | Output is correct |
3 | Correct | 2 ms | 16716 KB | Output is correct |
4 | Correct | 2 ms | 16716 KB | Output is correct |
5 | Correct | 2 ms | 16716 KB | Output is correct |
6 | Correct | 2 ms | 16716 KB | Output is correct |
7 | Correct | 2 ms | 16716 KB | Output is correct |
8 | Correct | 2 ms | 16716 KB | Output is correct |
9 | Correct | 2 ms | 16716 KB | Output is correct |
10 | Correct | 2 ms | 16716 KB | Output is correct |
11 | Correct | 2 ms | 16716 KB | Output is correct |
12 | Correct | 2 ms | 16716 KB | Output is correct |
13 | Correct | 2 ms | 16716 KB | Output is correct |
14 | Correct | 2 ms | 16716 KB | Output is correct |
15 | Correct | 2 ms | 16716 KB | Output is correct |
16 | Correct | 2 ms | 16716 KB | Output is correct |
17 | Correct | 2 ms | 16716 KB | Output is correct |
18 | Correct | 2 ms | 16716 KB | Output is correct |
19 | Correct | 2 ms | 16716 KB | Output is correct |
20 | Correct | 2 ms | 16716 KB | Output is correct |
21 | Correct | 2 ms | 16716 KB | Output is correct |
22 | Correct | 2 ms | 16716 KB | Output is correct |
23 | Correct | 2 ms | 16716 KB | Output is correct |
24 | Correct | 2 ms | 16716 KB | Output is correct |
25 | Correct | 2 ms | 16716 KB | Output is correct |
26 | Correct | 3 ms | 16716 KB | Output is correct |
27 | Correct | 3 ms | 16716 KB | Output is correct |
28 | Correct | 3 ms | 16716 KB | Output is correct |
29 | Correct | 3 ms | 16716 KB | Output is correct |
30 | Correct | 3 ms | 16716 KB | Output is correct |
31 | Correct | 3 ms | 16716 KB | Output is correct |
32 | Correct | 3 ms | 16716 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 16716 KB | Output is correct |
2 | Correct | 2 ms | 16716 KB | Output is correct |
3 | Correct | 2 ms | 16716 KB | Output is correct |
4 | Correct | 2 ms | 16716 KB | Output is correct |
5 | Correct | 2 ms | 16716 KB | Output is correct |
6 | Correct | 2 ms | 16716 KB | Output is correct |
7 | Correct | 2 ms | 16716 KB | Output is correct |
8 | Correct | 2 ms | 16716 KB | Output is correct |
9 | Correct | 2 ms | 16716 KB | Output is correct |
10 | Correct | 2 ms | 16716 KB | Output is correct |
11 | Correct | 2 ms | 16716 KB | Output is correct |
12 | Correct | 2 ms | 16716 KB | Output is correct |
13 | Correct | 2 ms | 16716 KB | Output is correct |
14 | Correct | 142 ms | 16804 KB | Output is correct |
15 | Correct | 127 ms | 16804 KB | Output is correct |
16 | Correct | 132 ms | 16892 KB | Output is correct |
17 | Correct | 133 ms | 16892 KB | Output is correct |
18 | Correct | 127 ms | 16892 KB | Output is correct |
19 | Correct | 131 ms | 16932 KB | Output is correct |
20 | Correct | 127 ms | 16932 KB | Output is correct |
21 | Correct | 130 ms | 16932 KB | Output is correct |
22 | Correct | 126 ms | 16932 KB | Output is correct |
23 | Correct | 126 ms | 16932 KB | Output is correct |
24 | Correct | 128 ms | 16932 KB | Output is correct |
25 | Correct | 129 ms | 16932 KB | Output is correct |
26 | Correct | 129 ms | 16932 KB | Output is correct |
27 | Correct | 2 ms | 16932 KB | Output is correct |
28 | Correct | 2 ms | 16932 KB | Output is correct |
29 | Correct | 2 ms | 16932 KB | Output is correct |
30 | Correct | 2 ms | 16932 KB | Output is correct |
31 | Correct | 2 ms | 16932 KB | Output is correct |
32 | Correct | 2 ms | 16932 KB | Output is correct |
33 | Correct | 2 ms | 16932 KB | Output is correct |
34 | Correct | 2 ms | 16932 KB | Output is correct |
35 | Correct | 3 ms | 16932 KB | Output is correct |
36 | Correct | 2 ms | 16932 KB | Output is correct |
37 | Correct | 3 ms | 16932 KB | Output is correct |
38 | Correct | 2 ms | 16932 KB | Output is correct |
39 | Correct | 2 ms | 16932 KB | Output is correct |
40 | Correct | 2 ms | 16932 KB | Output is correct |
41 | Correct | 2 ms | 16932 KB | Output is correct |
42 | Correct | 2 ms | 16932 KB | Output is correct |
43 | Correct | 2 ms | 16932 KB | Output is correct |
44 | Correct | 2 ms | 16932 KB | Output is correct |
45 | Correct | 2 ms | 16932 KB | Output is correct |
46 | Correct | 2 ms | 16932 KB | Output is correct |
47 | Correct | 2 ms | 16932 KB | Output is correct |
48 | Correct | 2 ms | 16932 KB | Output is correct |
49 | Correct | 2 ms | 16932 KB | Output is correct |
50 | Correct | 3 ms | 16932 KB | Output is correct |
51 | Correct | 3 ms | 16932 KB | Output is correct |
52 | Correct | 3 ms | 16932 KB | Output is correct |
53 | Correct | 3 ms | 16932 KB | Output is correct |
54 | Correct | 3 ms | 16932 KB | Output is correct |
55 | Correct | 3 ms | 16932 KB | Output is correct |
56 | Correct | 2 ms | 16932 KB | Output is correct |
57 | Correct | 2 ms | 16932 KB | Output is correct |
58 | Correct | 2 ms | 16932 KB | Output is correct |
59 | Correct | 3 ms | 16932 KB | Output is correct |
60 | Correct | 3 ms | 16932 KB | Output is correct |
61 | Correct | 3 ms | 16932 KB | Output is correct |
62 | Correct | 3 ms | 16932 KB | Output is correct |
63 | Correct | 2 ms | 16932 KB | Output is correct |
64 | Correct | 177 ms | 16932 KB | Output is correct |
65 | Correct | 132 ms | 16932 KB | Output is correct |
66 | Correct | 138 ms | 16932 KB | Output is correct |
67 | Correct | 147 ms | 16932 KB | Output is correct |
68 | Correct | 159 ms | 16932 KB | Output is correct |
69 | Correct | 172 ms | 16932 KB | Output is correct |
70 | Correct | 171 ms | 16932 KB | Output is correct |
71 | Correct | 169 ms | 16932 KB | Output is correct |
72 | Correct | 173 ms | 16932 KB | Output is correct |
73 | Correct | 170 ms | 16932 KB | Output is correct |
74 | Correct | 175 ms | 16932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 16932 KB | Output is correct |
2 | Correct | 2 ms | 16932 KB | Output is correct |
3 | Correct | 2 ms | 16932 KB | Output is correct |
4 | Correct | 2 ms | 16932 KB | Output is correct |
5 | Correct | 2 ms | 16932 KB | Output is correct |
6 | Correct | 2 ms | 16932 KB | Output is correct |
7 | Correct | 2 ms | 16932 KB | Output is correct |
8 | Correct | 2 ms | 16932 KB | Output is correct |
9 | Correct | 2 ms | 16932 KB | Output is correct |
10 | Correct | 2 ms | 16932 KB | Output is correct |
11 | Correct | 2 ms | 16932 KB | Output is correct |
12 | Correct | 2 ms | 16932 KB | Output is correct |
13 | Correct | 2 ms | 16932 KB | Output is correct |
14 | Correct | 2 ms | 16932 KB | Output is correct |
15 | Correct | 2 ms | 16932 KB | Output is correct |
16 | Correct | 2 ms | 16932 KB | Output is correct |
17 | Correct | 2 ms | 16932 KB | Output is correct |
18 | Correct | 2 ms | 16932 KB | Output is correct |
19 | Correct | 2 ms | 16932 KB | Output is correct |
20 | Correct | 2 ms | 16932 KB | Output is correct |
21 | Correct | 2 ms | 16932 KB | Output is correct |
22 | Correct | 2 ms | 16932 KB | Output is correct |
23 | Correct | 2 ms | 16932 KB | Output is correct |
24 | Correct | 2 ms | 16932 KB | Output is correct |
25 | Correct | 2 ms | 16932 KB | Output is correct |
26 | Correct | 2 ms | 16932 KB | Output is correct |
27 | Correct | 2 ms | 16932 KB | Output is correct |
28 | Correct | 2 ms | 16932 KB | Output is correct |
29 | Correct | 2 ms | 16932 KB | Output is correct |
30 | Correct | 2 ms | 16932 KB | Output is correct |
31 | Correct | 2 ms | 16932 KB | Output is correct |
32 | Correct | 2 ms | 16932 KB | Output is correct |
33 | Correct | 2 ms | 16932 KB | Output is correct |
34 | Correct | 2 ms | 16932 KB | Output is correct |
35 | Correct | 3 ms | 16932 KB | Output is correct |
36 | Correct | 2 ms | 16932 KB | Output is correct |
37 | Correct | 3 ms | 16932 KB | Output is correct |
38 | Correct | 3 ms | 16932 KB | Output is correct |
39 | Correct | 3 ms | 16932 KB | Output is correct |
40 | Correct | 3 ms | 16932 KB | Output is correct |
41 | Correct | 3 ms | 16932 KB | Output is correct |
42 | Correct | 3 ms | 16932 KB | Output is correct |
43 | Correct | 2 ms | 16932 KB | Output is correct |
44 | Correct | 3 ms | 16932 KB | Output is correct |
45 | Correct | 3 ms | 16932 KB | Output is correct |
46 | Correct | 3 ms | 16932 KB | Output is correct |
47 | Correct | 3 ms | 16932 KB | Output is correct |
48 | Correct | 3 ms | 16932 KB | Output is correct |
49 | Correct | 3 ms | 16932 KB | Output is correct |
50 | Correct | 3 ms | 16932 KB | Output is correct |
51 | Correct | 3 ms | 16932 KB | Output is correct |
52 | Correct | 24 ms | 16932 KB | Output is correct |
53 | Correct | 42 ms | 16932 KB | Output is correct |
54 | Correct | 87 ms | 16932 KB | Output is correct |
55 | Correct | 87 ms | 16932 KB | Output is correct |
56 | Correct | 397 ms | 16932 KB | Output is correct |
57 | Correct | 395 ms | 16932 KB | Output is correct |
58 | Correct | 347 ms | 16932 KB | Output is correct |
59 | Correct | 352 ms | 16932 KB | Output is correct |
60 | Correct | 477 ms | 16932 KB | Output is correct |
61 | Correct | 3 ms | 16932 KB | Output is correct |
62 | Correct | 41 ms | 16932 KB | Output is correct |
63 | Correct | 89 ms | 16932 KB | Output is correct |
64 | Correct | 79 ms | 16932 KB | Output is correct |
65 | Correct | 171 ms | 16932 KB | Output is correct |
66 | Correct | 279 ms | 16932 KB | Output is correct |
67 | Correct | 398 ms | 16932 KB | Output is correct |
68 | Correct | 406 ms | 16932 KB | Output is correct |
69 | Correct | 377 ms | 16932 KB | Output is correct |