#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <stack>
#include <map>
#include <math.h>
#include <bitset>
#include <deque>
#include <string>
#include <tuple>
#include <queue>
#include <numeric>
#include <complex>
#include <assert.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define ld long long double
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define mod 1000000007ll
#define INF 1e18
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define all(x) (x).begin (), (x).end ()
#define sz(x) (ll) (x).size ()
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())
#define rank rnk
#define log lg
#define fast \
ios_base::sync_with_stdio (false); \
cin.tie (NULL); \
cout.tie (NULL)
using namespace std;
signed main()
{
fast;
// freopen("curling.in","r",stdin);
// freopen("curling.out","w",stdout);
ll n,a,b;
cin>>n>>a>>b;
ll arr[n+1];
rep(i,1,n)
cin>>arr[i];
ll s[n+1];
s[0]=0;
rep(i,1,n)
s[i]=s[i-1]+arr[i];
ll ans=0;
for(ll idx=62;idx>=0;--idx)
{
ans+=(1ll<<idx)-1;
vector<vector<int>> adj(n+1);
rep(i,0,n)
rep(j,i+1,n)
if(((s[j]-s[i])&(~ans))==0)
adj[i].pb(j);
bool ok=false;
if(n<=100)
{
vector <vector<bool>> ispath(n+1,vector<bool>(n+1));
ispath[0][0]=true;
rep(i,0,n)
for(auto j:adj[i])
rep(cnt,0,n)
if(ispath[i][cnt])
ispath[j][cnt+1]=true;
rep(i,a,b)
if(ispath[n][i])
ok=true;
}
else
{
queue <ll> q;
vector <ll> d(n+1,INF);
q.push(0);
d[0]=0;
while(!q.empty())
{
auto v=q.front();
q.pop();
for(auto u:adj[v])
if(d[u]==INF)
{
d[u]=1+d[v];
q.push(u);
}
}
if(d[n]<=b)
ok=true;
}
if(ok)
ans-=(1ll<<idx)-1;
else
ans+=1;
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
2 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
212 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
2 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
2 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
2 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
2 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
2 ms |
212 KB |
Output is correct |
29 |
Correct |
5 ms |
212 KB |
Output is correct |
30 |
Correct |
5 ms |
212 KB |
Output is correct |
31 |
Correct |
8 ms |
212 KB |
Output is correct |
32 |
Correct |
9 ms |
332 KB |
Output is correct |
33 |
Correct |
8 ms |
332 KB |
Output is correct |
34 |
Correct |
8 ms |
332 KB |
Output is correct |
35 |
Correct |
8 ms |
212 KB |
Output is correct |
36 |
Correct |
8 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
212 KB |
Output is correct |
15 |
Correct |
2 ms |
212 KB |
Output is correct |
16 |
Correct |
4 ms |
212 KB |
Output is correct |
17 |
Correct |
5 ms |
212 KB |
Output is correct |
18 |
Correct |
8 ms |
212 KB |
Output is correct |
19 |
Correct |
8 ms |
212 KB |
Output is correct |
20 |
Correct |
8 ms |
212 KB |
Output is correct |
21 |
Correct |
10 ms |
212 KB |
Output is correct |
22 |
Correct |
9 ms |
212 KB |
Output is correct |
23 |
Correct |
10 ms |
328 KB |
Output is correct |
24 |
Correct |
9 ms |
328 KB |
Output is correct |
25 |
Correct |
16 ms |
340 KB |
Output is correct |
26 |
Correct |
26 ms |
340 KB |
Output is correct |
27 |
Correct |
38 ms |
340 KB |
Output is correct |
28 |
Correct |
50 ms |
340 KB |
Output is correct |
29 |
Correct |
52 ms |
340 KB |
Output is correct |
30 |
Correct |
52 ms |
340 KB |
Output is correct |
31 |
Correct |
51 ms |
340 KB |
Output is correct |
32 |
Correct |
51 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
37 |
Correct |
1 ms |
212 KB |
Output is correct |
38 |
Correct |
2 ms |
212 KB |
Output is correct |
39 |
Correct |
4 ms |
212 KB |
Output is correct |
40 |
Correct |
6 ms |
212 KB |
Output is correct |
41 |
Correct |
10 ms |
212 KB |
Output is correct |
42 |
Correct |
8 ms |
328 KB |
Output is correct |
43 |
Correct |
8 ms |
212 KB |
Output is correct |
44 |
Correct |
8 ms |
324 KB |
Output is correct |
45 |
Correct |
8 ms |
212 KB |
Output is correct |
46 |
Correct |
9 ms |
324 KB |
Output is correct |
47 |
Correct |
9 ms |
212 KB |
Output is correct |
48 |
Correct |
19 ms |
340 KB |
Output is correct |
49 |
Correct |
25 ms |
340 KB |
Output is correct |
50 |
Correct |
39 ms |
340 KB |
Output is correct |
51 |
Correct |
52 ms |
340 KB |
Output is correct |
52 |
Correct |
50 ms |
340 KB |
Output is correct |
53 |
Correct |
53 ms |
340 KB |
Output is correct |
54 |
Correct |
69 ms |
340 KB |
Output is correct |
55 |
Correct |
52 ms |
340 KB |
Output is correct |
56 |
Correct |
5 ms |
328 KB |
Output is correct |
57 |
Correct |
15 ms |
340 KB |
Output is correct |
58 |
Correct |
22 ms |
340 KB |
Output is correct |
59 |
Correct |
29 ms |
340 KB |
Output is correct |
60 |
Correct |
31 ms |
340 KB |
Output is correct |
61 |
Correct |
29 ms |
340 KB |
Output is correct |
62 |
Correct |
33 ms |
340 KB |
Output is correct |
63 |
Correct |
31 ms |
340 KB |
Output is correct |
64 |
Correct |
40 ms |
340 KB |
Output is correct |
65 |
Correct |
5 ms |
212 KB |
Output is correct |
66 |
Correct |
9 ms |
336 KB |
Output is correct |
67 |
Correct |
15 ms |
344 KB |
Output is correct |
68 |
Correct |
25 ms |
340 KB |
Output is correct |
69 |
Correct |
35 ms |
340 KB |
Output is correct |
70 |
Correct |
27 ms |
340 KB |
Output is correct |
71 |
Correct |
29 ms |
340 KB |
Output is correct |
72 |
Correct |
33 ms |
340 KB |
Output is correct |
73 |
Correct |
31 ms |
340 KB |
Output is correct |
74 |
Correct |
32 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
2 ms |
212 KB |
Output is correct |
26 |
Correct |
4 ms |
212 KB |
Output is correct |
27 |
Correct |
6 ms |
324 KB |
Output is correct |
28 |
Correct |
8 ms |
212 KB |
Output is correct |
29 |
Correct |
8 ms |
332 KB |
Output is correct |
30 |
Correct |
9 ms |
324 KB |
Output is correct |
31 |
Correct |
8 ms |
212 KB |
Output is correct |
32 |
Correct |
8 ms |
212 KB |
Output is correct |
33 |
Correct |
8 ms |
324 KB |
Output is correct |
34 |
Correct |
8 ms |
328 KB |
Output is correct |
35 |
Correct |
15 ms |
340 KB |
Output is correct |
36 |
Correct |
25 ms |
340 KB |
Output is correct |
37 |
Correct |
44 ms |
340 KB |
Output is correct |
38 |
Correct |
54 ms |
348 KB |
Output is correct |
39 |
Correct |
54 ms |
460 KB |
Output is correct |
40 |
Correct |
53 ms |
340 KB |
Output is correct |
41 |
Correct |
50 ms |
340 KB |
Output is correct |
42 |
Correct |
51 ms |
340 KB |
Output is correct |
43 |
Correct |
5 ms |
284 KB |
Output is correct |
44 |
Correct |
15 ms |
336 KB |
Output is correct |
45 |
Correct |
22 ms |
340 KB |
Output is correct |
46 |
Correct |
28 ms |
340 KB |
Output is correct |
47 |
Correct |
29 ms |
356 KB |
Output is correct |
48 |
Correct |
28 ms |
356 KB |
Output is correct |
49 |
Correct |
32 ms |
340 KB |
Output is correct |
50 |
Correct |
31 ms |
344 KB |
Output is correct |
51 |
Correct |
2 ms |
348 KB |
Output is correct |
52 |
Correct |
30 ms |
1280 KB |
Output is correct |
53 |
Correct |
48 ms |
2092 KB |
Output is correct |
54 |
Correct |
85 ms |
3028 KB |
Output is correct |
55 |
Correct |
85 ms |
3144 KB |
Output is correct |
56 |
Correct |
299 ms |
11024 KB |
Output is correct |
57 |
Correct |
305 ms |
11024 KB |
Output is correct |
58 |
Correct |
302 ms |
10972 KB |
Output is correct |
59 |
Correct |
294 ms |
10984 KB |
Output is correct |
60 |
Correct |
304 ms |
11032 KB |
Output is correct |
61 |
Correct |
3 ms |
340 KB |
Output is correct |
62 |
Correct |
48 ms |
1876 KB |
Output is correct |
63 |
Correct |
88 ms |
3028 KB |
Output is correct |
64 |
Correct |
76 ms |
3028 KB |
Output is correct |
65 |
Correct |
154 ms |
6200 KB |
Output is correct |
66 |
Correct |
238 ms |
8896 KB |
Output is correct |
67 |
Correct |
313 ms |
10964 KB |
Output is correct |
68 |
Correct |
311 ms |
11024 KB |
Output is correct |
69 |
Correct |
284 ms |
11020 KB |
Output is correct |