//#define _GLIBCXX_DEBUG
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//
//using namespace __gnu_pbds;
//
//template<typename T>
//using ordered_set = tree<T, null_type, less < T>, rb_tree_tag, tree_order_statistics_node_update>;
//template<typename T>
//using normal_queue = priority_queue<T, vector<T>, greater<>>;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define trace(x) cout << #x << ": " << (x) << endl;
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define uniq(x) x.resize(unique(all(x)) - begin(x))
#define sz(s) ((int) size(s))
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
#define int128 __int128
#define pb push_back
#define popb pop_back
#define eb emplace_back
#define fi first
#define se second
#define itn int
typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
template<typename T>
bool ckmn(T &x, T y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template<typename T>
bool ckmx(T &x, T y) {
if (x < y) {
x = y;
return true;
}
return false;
}
int bit(int x, int b) {
return (x >> b) & 1;
}
int rand(int l, int r) { return (int) ((ll) rnd() % (r - l + 1)) + l; }
const ll infL = 3e18;
const int infI = 1000000000 + 7;
const int infM = 0x3f3f3f3f; //a little bigger than 1e9
const ll infML = 0x3f3f3f3f3f3f3f3fLL; //4.5e18
const int N = 2002;
const int mod = 998244353;
const ld eps = 1e-9;
const int logn = __lg(N * 1000000000LL) + 1;
bitset<N> dp[N];
int a[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, L, R;
cin >> n >> L >> R;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
ll ans = 0;
dp[0][0] = true;
for (int bt = logn - 1; bt > -1; --bt) {
for (int i = 1; i <= n; ++i) {
dp[i] = 0;
}
ll x = ans;
for (int b = bt - 1; b > -1; --b) {
x += (1LL << b);
}
for (int i = 1; i <= n; ++i) {
ll sum = 0;
for (int j = i - 1; j > -1; --j) {
sum += a[j + 1];
if ((sum & x) == sum) {
dp[i] |= (dp[j] << 1);
}
}
}
bool ok = false;
for (int i = L; i <= R; ++i) {
if (dp[n][i]) {
ok = true;
break;
}
}
if (!ok) {
ans += (1LL << bt);
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
340 KB |
Output is correct |
29 |
Correct |
3 ms |
340 KB |
Output is correct |
30 |
Correct |
3 ms |
336 KB |
Output is correct |
31 |
Correct |
5 ms |
340 KB |
Output is correct |
32 |
Correct |
5 ms |
340 KB |
Output is correct |
33 |
Correct |
4 ms |
340 KB |
Output is correct |
34 |
Correct |
3 ms |
340 KB |
Output is correct |
35 |
Correct |
3 ms |
352 KB |
Output is correct |
36 |
Correct |
4 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
3 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
340 KB |
Output is correct |
20 |
Correct |
4 ms |
340 KB |
Output is correct |
21 |
Correct |
4 ms |
328 KB |
Output is correct |
22 |
Correct |
4 ms |
336 KB |
Output is correct |
23 |
Correct |
4 ms |
340 KB |
Output is correct |
24 |
Correct |
3 ms |
340 KB |
Output is correct |
25 |
Correct |
5 ms |
356 KB |
Output is correct |
26 |
Correct |
7 ms |
340 KB |
Output is correct |
27 |
Correct |
9 ms |
444 KB |
Output is correct |
28 |
Correct |
11 ms |
340 KB |
Output is correct |
29 |
Correct |
12 ms |
340 KB |
Output is correct |
30 |
Correct |
12 ms |
360 KB |
Output is correct |
31 |
Correct |
13 ms |
364 KB |
Output is correct |
32 |
Correct |
13 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
464 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
2 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
1 ms |
336 KB |
Output is correct |
38 |
Correct |
1 ms |
336 KB |
Output is correct |
39 |
Correct |
2 ms |
340 KB |
Output is correct |
40 |
Correct |
3 ms |
340 KB |
Output is correct |
41 |
Correct |
5 ms |
340 KB |
Output is correct |
42 |
Correct |
4 ms |
340 KB |
Output is correct |
43 |
Correct |
4 ms |
340 KB |
Output is correct |
44 |
Correct |
4 ms |
340 KB |
Output is correct |
45 |
Correct |
5 ms |
340 KB |
Output is correct |
46 |
Correct |
3 ms |
340 KB |
Output is correct |
47 |
Correct |
4 ms |
340 KB |
Output is correct |
48 |
Correct |
5 ms |
340 KB |
Output is correct |
49 |
Correct |
7 ms |
340 KB |
Output is correct |
50 |
Correct |
10 ms |
364 KB |
Output is correct |
51 |
Correct |
13 ms |
364 KB |
Output is correct |
52 |
Correct |
11 ms |
340 KB |
Output is correct |
53 |
Correct |
12 ms |
340 KB |
Output is correct |
54 |
Correct |
12 ms |
340 KB |
Output is correct |
55 |
Correct |
12 ms |
340 KB |
Output is correct |
56 |
Correct |
2 ms |
340 KB |
Output is correct |
57 |
Correct |
3 ms |
328 KB |
Output is correct |
58 |
Correct |
3 ms |
340 KB |
Output is correct |
59 |
Correct |
4 ms |
332 KB |
Output is correct |
60 |
Correct |
3 ms |
340 KB |
Output is correct |
61 |
Correct |
3 ms |
340 KB |
Output is correct |
62 |
Correct |
5 ms |
368 KB |
Output is correct |
63 |
Correct |
5 ms |
332 KB |
Output is correct |
64 |
Correct |
11 ms |
364 KB |
Output is correct |
65 |
Correct |
2 ms |
340 KB |
Output is correct |
66 |
Correct |
2 ms |
340 KB |
Output is correct |
67 |
Correct |
3 ms |
340 KB |
Output is correct |
68 |
Correct |
3 ms |
340 KB |
Output is correct |
69 |
Correct |
4 ms |
340 KB |
Output is correct |
70 |
Correct |
3 ms |
340 KB |
Output is correct |
71 |
Correct |
4 ms |
340 KB |
Output is correct |
72 |
Correct |
8 ms |
336 KB |
Output is correct |
73 |
Correct |
5 ms |
340 KB |
Output is correct |
74 |
Correct |
5 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
3 ms |
340 KB |
Output is correct |
28 |
Correct |
3 ms |
336 KB |
Output is correct |
29 |
Correct |
3 ms |
340 KB |
Output is correct |
30 |
Correct |
4 ms |
332 KB |
Output is correct |
31 |
Correct |
3 ms |
340 KB |
Output is correct |
32 |
Correct |
3 ms |
340 KB |
Output is correct |
33 |
Correct |
4 ms |
340 KB |
Output is correct |
34 |
Correct |
3 ms |
336 KB |
Output is correct |
35 |
Correct |
5 ms |
340 KB |
Output is correct |
36 |
Correct |
7 ms |
332 KB |
Output is correct |
37 |
Correct |
9 ms |
336 KB |
Output is correct |
38 |
Correct |
12 ms |
340 KB |
Output is correct |
39 |
Correct |
12 ms |
340 KB |
Output is correct |
40 |
Correct |
16 ms |
352 KB |
Output is correct |
41 |
Correct |
16 ms |
360 KB |
Output is correct |
42 |
Correct |
12 ms |
340 KB |
Output is correct |
43 |
Correct |
2 ms |
336 KB |
Output is correct |
44 |
Correct |
3 ms |
340 KB |
Output is correct |
45 |
Correct |
3 ms |
340 KB |
Output is correct |
46 |
Correct |
4 ms |
328 KB |
Output is correct |
47 |
Correct |
3 ms |
340 KB |
Output is correct |
48 |
Correct |
5 ms |
340 KB |
Output is correct |
49 |
Correct |
4 ms |
340 KB |
Output is correct |
50 |
Correct |
5 ms |
340 KB |
Output is correct |
51 |
Correct |
3 ms |
340 KB |
Output is correct |
52 |
Correct |
56 ms |
472 KB |
Output is correct |
53 |
Correct |
88 ms |
520 KB |
Output is correct |
54 |
Correct |
161 ms |
596 KB |
Output is correct |
55 |
Correct |
144 ms |
596 KB |
Output is correct |
56 |
Correct |
431 ms |
852 KB |
Output is correct |
57 |
Correct |
426 ms |
852 KB |
Output is correct |
58 |
Correct |
320 ms |
852 KB |
Output is correct |
59 |
Correct |
333 ms |
860 KB |
Output is correct |
60 |
Correct |
522 ms |
852 KB |
Output is correct |
61 |
Correct |
5 ms |
340 KB |
Output is correct |
62 |
Correct |
90 ms |
520 KB |
Output is correct |
63 |
Correct |
194 ms |
596 KB |
Output is correct |
64 |
Correct |
131 ms |
596 KB |
Output is correct |
65 |
Correct |
276 ms |
692 KB |
Output is correct |
66 |
Correct |
337 ms |
776 KB |
Output is correct |
67 |
Correct |
479 ms |
852 KB |
Output is correct |
68 |
Correct |
478 ms |
852 KB |
Output is correct |
69 |
Correct |
425 ms |
844 KB |
Output is correct |