#include <bits/stdc++.h>
using namespace std;
#define OPTM ios_base::sync_with_stdio(0); cin.tie(0);
#define INF int(1e9+7)
#define ln '\n'
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define FOR(i,s,n) for (int i = s; i < n; i++)
#define FORR(i,n,s) for (int i = n; i > s; i--)
#define FORX(u, arr) for (auto u : arr)
#define PB push_back
#define in(v,x) (v.find(x) != v.end())
#define F first
#define S second
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define UM unordered_map
#define US unordered_set
#define PQ priority_queue
#define ALL(v) v.begin(), v.end()
const ll LLINF = 1e18+1;
#define int long long
const int MAXN = 1e2+1, LOG = 41;
int n,A,B;
int a[MAXN], p[MAXN], res[LOG];
bool dp[MAXN][MAXN], valid[MAXN][MAXN];
vector<int> v[MAXN][MAXN];
signed main() {
OPTM;
cin >> n >> A >> B;
FOR(i,0,n) cin >> a[i];
FOR(i,1,n+1) p[i] = p[i-1]+a[i-1];
dp[0][0] = 1;
FOR(i,0,n) FOR(j,i,n) valid[i][j] = 1;
FOR(i,0,n) {
FOR(j,i,n) {
int x = p[j+1]-p[i];
while (x > 0) {
v[i][j].PB(x%2);
x /= 2;
}
int vn = v[i][j].size();
FOR(k,0,LOG-vn) v[i][j].PB(0);
}
}
FORR(k,LOG-1,-1) {
FOR(i,0,n+1) {
FOR(j,1,n+1) dp[i][j] = 0;
}
FOR(j,0,n) {
FOR(i,0,n+1) {
FOR(l,i+1,n+1) {
dp[l][j+1] = dp[l][j+1] || (dp[i][j] && valid[i][l-1] && !v[i][l-1][k]);
}
}
}
res[k] = 1;
FOR(x,A,B+1) {
if (dp[n][x]) res[k] = 0;
}
FOR(i,0,n) {
FOR(j,i,n) {
if (v[i][j][k] && !res[k]) valid[i][j] = 0;
}
}
}
int ans = 0, cur = 1;
FOR(k,0,LOG+1) {
ans += cur*res[k];
cur *= 2;
}
cout << ans;
}
Compilation message
sculpture.cpp: In function 'int main()':
sculpture.cpp:73:25: warning: iteration 41 invokes undefined behavior [-Waggressive-loop-optimizations]
73 | ans += cur*res[k];
| ~~~~~^
sculpture.cpp:10:38: note: within this loop
10 | #define FOR(i,s,n) for (int i = s; i < n; i++)
......
72 | FOR(k,0,LOG+1) {
| ~~~~~~~~~
sculpture.cpp:72:5: note: in expansion of macro 'FOR'
72 | FOR(k,0,LOG+1) {
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
568 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
564 KB |
Output is correct |
8 |
Correct |
2 ms |
596 KB |
Output is correct |
9 |
Correct |
2 ms |
568 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
2 ms |
596 KB |
Output is correct |
12 |
Correct |
2 ms |
596 KB |
Output is correct |
13 |
Correct |
2 ms |
568 KB |
Output is correct |
14 |
Correct |
1 ms |
488 KB |
Output is correct |
15 |
Correct |
1 ms |
548 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
1 ms |
596 KB |
Output is correct |
20 |
Correct |
2 ms |
572 KB |
Output is correct |
21 |
Correct |
2 ms |
684 KB |
Output is correct |
22 |
Correct |
2 ms |
596 KB |
Output is correct |
23 |
Correct |
2 ms |
640 KB |
Output is correct |
24 |
Correct |
2 ms |
644 KB |
Output is correct |
25 |
Correct |
2 ms |
596 KB |
Output is correct |
26 |
Correct |
2 ms |
596 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
564 KB |
Output is correct |
29 |
Correct |
1 ms |
596 KB |
Output is correct |
30 |
Correct |
1 ms |
596 KB |
Output is correct |
31 |
Correct |
2 ms |
596 KB |
Output is correct |
32 |
Correct |
2 ms |
596 KB |
Output is correct |
33 |
Correct |
2 ms |
560 KB |
Output is correct |
34 |
Correct |
2 ms |
596 KB |
Output is correct |
35 |
Correct |
3 ms |
568 KB |
Output is correct |
36 |
Correct |
2 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
2 ms |
592 KB |
Output is correct |
8 |
Correct |
3 ms |
596 KB |
Output is correct |
9 |
Correct |
2 ms |
568 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
2 ms |
596 KB |
Output is correct |
12 |
Correct |
2 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
568 KB |
Output is correct |
14 |
Correct |
1 ms |
568 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
564 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
2 ms |
596 KB |
Output is correct |
21 |
Correct |
1 ms |
572 KB |
Output is correct |
22 |
Correct |
2 ms |
596 KB |
Output is correct |
23 |
Correct |
2 ms |
596 KB |
Output is correct |
24 |
Correct |
2 ms |
596 KB |
Output is correct |
25 |
Correct |
2 ms |
684 KB |
Output is correct |
26 |
Correct |
2 ms |
568 KB |
Output is correct |
27 |
Correct |
2 ms |
596 KB |
Output is correct |
28 |
Correct |
2 ms |
724 KB |
Output is correct |
29 |
Correct |
5 ms |
964 KB |
Output is correct |
30 |
Correct |
7 ms |
1052 KB |
Output is correct |
31 |
Correct |
10 ms |
1204 KB |
Output is correct |
32 |
Correct |
10 ms |
1240 KB |
Output is correct |
33 |
Correct |
9 ms |
1236 KB |
Output is correct |
34 |
Correct |
12 ms |
1236 KB |
Output is correct |
35 |
Correct |
13 ms |
1208 KB |
Output is correct |
36 |
Correct |
9 ms |
1236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
572 KB |
Output is correct |
5 |
Correct |
1 ms |
568 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
568 KB |
Output is correct |
8 |
Correct |
2 ms |
596 KB |
Output is correct |
9 |
Correct |
2 ms |
596 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
2 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
4 ms |
596 KB |
Output is correct |
14 |
Correct |
1 ms |
596 KB |
Output is correct |
15 |
Correct |
4 ms |
724 KB |
Output is correct |
16 |
Correct |
7 ms |
964 KB |
Output is correct |
17 |
Correct |
8 ms |
952 KB |
Output is correct |
18 |
Correct |
11 ms |
1248 KB |
Output is correct |
19 |
Correct |
16 ms |
1236 KB |
Output is correct |
20 |
Correct |
10 ms |
1240 KB |
Output is correct |
21 |
Correct |
10 ms |
1244 KB |
Output is correct |
22 |
Correct |
11 ms |
1252 KB |
Output is correct |
23 |
Correct |
11 ms |
1248 KB |
Output is correct |
24 |
Correct |
12 ms |
1272 KB |
Output is correct |
25 |
Correct |
23 ms |
1704 KB |
Output is correct |
26 |
Correct |
34 ms |
2172 KB |
Output is correct |
27 |
Correct |
51 ms |
2656 KB |
Output is correct |
28 |
Correct |
67 ms |
3136 KB |
Output is correct |
29 |
Correct |
64 ms |
3176 KB |
Output is correct |
30 |
Correct |
66 ms |
3176 KB |
Output is correct |
31 |
Correct |
73 ms |
3172 KB |
Output is correct |
32 |
Correct |
63 ms |
3184 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
564 KB |
Output is correct |
6 |
Correct |
1 ms |
568 KB |
Output is correct |
7 |
Correct |
1 ms |
568 KB |
Output is correct |
8 |
Correct |
2 ms |
544 KB |
Output is correct |
9 |
Correct |
2 ms |
600 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
2 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
2 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
568 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
1 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
568 KB |
Output is correct |
21 |
Correct |
1 ms |
596 KB |
Output is correct |
22 |
Correct |
3 ms |
596 KB |
Output is correct |
23 |
Correct |
2 ms |
596 KB |
Output is correct |
24 |
Correct |
2 ms |
596 KB |
Output is correct |
25 |
Correct |
2 ms |
596 KB |
Output is correct |
26 |
Correct |
2 ms |
596 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
604 KB |
Output is correct |
29 |
Correct |
2 ms |
632 KB |
Output is correct |
30 |
Correct |
2 ms |
596 KB |
Output is correct |
31 |
Correct |
2 ms |
596 KB |
Output is correct |
32 |
Correct |
2 ms |
596 KB |
Output is correct |
33 |
Correct |
2 ms |
596 KB |
Output is correct |
34 |
Correct |
2 ms |
596 KB |
Output is correct |
35 |
Correct |
2 ms |
596 KB |
Output is correct |
36 |
Correct |
1 ms |
568 KB |
Output is correct |
37 |
Correct |
2 ms |
596 KB |
Output is correct |
38 |
Correct |
3 ms |
724 KB |
Output is correct |
39 |
Correct |
4 ms |
852 KB |
Output is correct |
40 |
Correct |
6 ms |
948 KB |
Output is correct |
41 |
Correct |
8 ms |
1236 KB |
Output is correct |
42 |
Correct |
9 ms |
1236 KB |
Output is correct |
43 |
Correct |
12 ms |
1208 KB |
Output is correct |
44 |
Correct |
12 ms |
1244 KB |
Output is correct |
45 |
Correct |
11 ms |
1252 KB |
Output is correct |
46 |
Correct |
11 ms |
1224 KB |
Output is correct |
47 |
Correct |
9 ms |
1236 KB |
Output is correct |
48 |
Correct |
17 ms |
1620 KB |
Output is correct |
49 |
Correct |
28 ms |
2132 KB |
Output is correct |
50 |
Correct |
60 ms |
2644 KB |
Output is correct |
51 |
Correct |
58 ms |
3168 KB |
Output is correct |
52 |
Correct |
56 ms |
3176 KB |
Output is correct |
53 |
Correct |
61 ms |
3172 KB |
Output is correct |
54 |
Correct |
64 ms |
3176 KB |
Output is correct |
55 |
Correct |
58 ms |
3156 KB |
Output is correct |
56 |
Correct |
11 ms |
1268 KB |
Output is correct |
57 |
Correct |
38 ms |
2132 KB |
Output is correct |
58 |
Correct |
48 ms |
2728 KB |
Output is correct |
59 |
Correct |
77 ms |
3180 KB |
Output is correct |
60 |
Correct |
60 ms |
3176 KB |
Output is correct |
61 |
Correct |
60 ms |
3156 KB |
Output is correct |
62 |
Correct |
70 ms |
3156 KB |
Output is correct |
63 |
Correct |
69 ms |
3168 KB |
Output is correct |
64 |
Correct |
42 ms |
2644 KB |
Output is correct |
65 |
Correct |
10 ms |
1208 KB |
Output is correct |
66 |
Correct |
18 ms |
1588 KB |
Output is correct |
67 |
Correct |
29 ms |
2132 KB |
Output is correct |
68 |
Correct |
48 ms |
2728 KB |
Output is correct |
69 |
Correct |
64 ms |
3172 KB |
Output is correct |
70 |
Correct |
65 ms |
3156 KB |
Output is correct |
71 |
Correct |
67 ms |
3156 KB |
Output is correct |
72 |
Correct |
58 ms |
3172 KB |
Output is correct |
73 |
Correct |
59 ms |
3172 KB |
Output is correct |
74 |
Correct |
57 ms |
3156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
564 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
596 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 |
596 KB |
Output is correct |
9 |
Correct |
1 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
596 KB |
Output is correct |
17 |
Correct |
2 ms |
596 KB |
Output is correct |
18 |
Correct |
2 ms |
596 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
2 ms |
596 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
2 ms |
596 KB |
Output is correct |
23 |
Correct |
1 ms |
596 KB |
Output is correct |
24 |
Correct |
1 ms |
596 KB |
Output is correct |
25 |
Correct |
2 ms |
724 KB |
Output is correct |
26 |
Correct |
4 ms |
852 KB |
Output is correct |
27 |
Correct |
5 ms |
980 KB |
Output is correct |
28 |
Correct |
9 ms |
1240 KB |
Output is correct |
29 |
Correct |
9 ms |
1204 KB |
Output is correct |
30 |
Correct |
9 ms |
1244 KB |
Output is correct |
31 |
Correct |
9 ms |
1236 KB |
Output is correct |
32 |
Correct |
9 ms |
1236 KB |
Output is correct |
33 |
Correct |
8 ms |
1236 KB |
Output is correct |
34 |
Correct |
9 ms |
1236 KB |
Output is correct |
35 |
Correct |
17 ms |
1692 KB |
Output is correct |
36 |
Correct |
29 ms |
2176 KB |
Output is correct |
37 |
Correct |
46 ms |
2644 KB |
Output is correct |
38 |
Correct |
56 ms |
3084 KB |
Output is correct |
39 |
Correct |
68 ms |
3156 KB |
Output is correct |
40 |
Correct |
69 ms |
3172 KB |
Output is correct |
41 |
Correct |
58 ms |
3168 KB |
Output is correct |
42 |
Correct |
59 ms |
3184 KB |
Output is correct |
43 |
Correct |
9 ms |
1236 KB |
Output is correct |
44 |
Correct |
31 ms |
2132 KB |
Output is correct |
45 |
Correct |
52 ms |
2732 KB |
Output is correct |
46 |
Correct |
62 ms |
3156 KB |
Output is correct |
47 |
Correct |
58 ms |
3172 KB |
Output is correct |
48 |
Correct |
58 ms |
3156 KB |
Output is correct |
49 |
Correct |
57 ms |
3128 KB |
Output is correct |
50 |
Correct |
59 ms |
3164 KB |
Output is correct |
51 |
Incorrect |
62 ms |
3228 KB |
Output isn't correct |
52 |
Halted |
0 ms |
0 KB |
- |