#include <bits/stdc++.h>
#define forinc(i,a,b) for(int i = a, _key = b; i <= _key; i++)
#define fordec(i,a,b) for(int i = a, _key = b; i >= _key; i--)
#define fori(i,n) for(int i = 0, _key = n; i < _key; i++)
#define ford(i,n) for(int i = n - 1; i >= 0; i--)
#define forvct(i,v) for(int i = 0, _key = v.size(); i < _key; i++)
#define task "sculpture"
#define st first
#define nd second
#define m_p make_pair
#define p_b push_back
#define p_f push_front
#define pp_b pop_back
#define pp_f pop_front
#define sn string::npos
#define ll long long
#define db double
#define str string
#define base 1000000007
#define nn 2010
using namespace std;
int n, a, b;
bool f1[110][110];
int f2[nn];
long long s[nn], key;
bool subset(const ll &x, const ll &y)
{
return (x & y) == x;
}
void enter()
{
cin >> n >> a >> b;
b = min(b,n);
int x;
forinc(i,1,n)
{
cin >> x;
s[i] = s[i-1] + x;
}
}
bool check1(const int &p)
{
memset(f1,false,sizeof f1);
f1[0][0] = true;
forinc(i,1,n)
forinc(g,1,i)
forinc(j,0,i-1)
if (f1[j][g-1] && subset((s[i] - s[j]) >> p,key))
{
f1[i][g] = true;
break;
}
forinc(g,a,b) if (f1[n][g]) return true;
return false;
}
bool check2(const int &p)
{
forinc(i,1,n) f2[i] = n + 1;
forinc(i,1,n)
forinc(j,0,i-1)
if (subset((s[i] - s[j]) >> p,key))
f2[i] = min(f2[i],f2[j] + 1);
return (f2[n] <= b);
}
void process()
{
key = 0;
fordec(p,40,0)
{
key = (key << 1);
if (!((a > 1 && check1(p)) || (a == 1 && check2(p)))) key |= 1;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
//freopen(task".inp","r",stdin);
//freopen(task".out","w",stdout);
enter();
process();
cout << key;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2216 KB |
Output is correct |
2 |
Correct |
0 ms |
2216 KB |
Output is correct |
3 |
Correct |
0 ms |
2216 KB |
Output is correct |
4 |
Correct |
0 ms |
2216 KB |
Output is correct |
5 |
Correct |
0 ms |
2216 KB |
Output is correct |
6 |
Correct |
0 ms |
2216 KB |
Output is correct |
7 |
Correct |
0 ms |
2216 KB |
Output is correct |
8 |
Correct |
0 ms |
2216 KB |
Output is correct |
9 |
Correct |
0 ms |
2216 KB |
Output is correct |
10 |
Correct |
0 ms |
2216 KB |
Output is correct |
11 |
Correct |
0 ms |
2216 KB |
Output is correct |
12 |
Correct |
0 ms |
2216 KB |
Output is correct |
13 |
Correct |
0 ms |
2216 KB |
Output is correct |
14 |
Correct |
0 ms |
2216 KB |
Output is correct |
15 |
Correct |
0 ms |
2216 KB |
Output is correct |
16 |
Correct |
0 ms |
2216 KB |
Output is correct |
17 |
Correct |
0 ms |
2216 KB |
Output is correct |
18 |
Correct |
0 ms |
2216 KB |
Output is correct |
19 |
Correct |
0 ms |
2216 KB |
Output is correct |
20 |
Correct |
0 ms |
2216 KB |
Output is correct |
21 |
Correct |
0 ms |
2216 KB |
Output is correct |
22 |
Correct |
0 ms |
2216 KB |
Output is correct |
23 |
Correct |
0 ms |
2216 KB |
Output is correct |
24 |
Correct |
0 ms |
2216 KB |
Output is correct |
25 |
Correct |
0 ms |
2216 KB |
Output is correct |
26 |
Correct |
0 ms |
2216 KB |
Output is correct |
27 |
Correct |
0 ms |
2216 KB |
Output is correct |
28 |
Correct |
0 ms |
2216 KB |
Output is correct |
29 |
Correct |
0 ms |
2216 KB |
Output is correct |
30 |
Correct |
0 ms |
2216 KB |
Output is correct |
31 |
Correct |
0 ms |
2216 KB |
Output is correct |
32 |
Correct |
0 ms |
2216 KB |
Output is correct |
33 |
Correct |
0 ms |
2216 KB |
Output is correct |
34 |
Correct |
0 ms |
2216 KB |
Output is correct |
35 |
Correct |
0 ms |
2216 KB |
Output is correct |
36 |
Correct |
0 ms |
2216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2216 KB |
Output is correct |
2 |
Correct |
0 ms |
2216 KB |
Output is correct |
3 |
Correct |
0 ms |
2216 KB |
Output is correct |
4 |
Correct |
0 ms |
2216 KB |
Output is correct |
5 |
Correct |
0 ms |
2216 KB |
Output is correct |
6 |
Correct |
0 ms |
2216 KB |
Output is correct |
7 |
Correct |
0 ms |
2216 KB |
Output is correct |
8 |
Correct |
0 ms |
2216 KB |
Output is correct |
9 |
Correct |
0 ms |
2216 KB |
Output is correct |
10 |
Correct |
0 ms |
2216 KB |
Output is correct |
11 |
Correct |
0 ms |
2216 KB |
Output is correct |
12 |
Correct |
0 ms |
2216 KB |
Output is correct |
13 |
Correct |
0 ms |
2216 KB |
Output is correct |
14 |
Correct |
0 ms |
2216 KB |
Output is correct |
15 |
Correct |
0 ms |
2216 KB |
Output is correct |
16 |
Correct |
0 ms |
2216 KB |
Output is correct |
17 |
Correct |
0 ms |
2216 KB |
Output is correct |
18 |
Correct |
0 ms |
2216 KB |
Output is correct |
19 |
Correct |
0 ms |
2216 KB |
Output is correct |
20 |
Correct |
0 ms |
2216 KB |
Output is correct |
21 |
Correct |
0 ms |
2216 KB |
Output is correct |
22 |
Correct |
0 ms |
2216 KB |
Output is correct |
23 |
Correct |
0 ms |
2216 KB |
Output is correct |
24 |
Correct |
0 ms |
2216 KB |
Output is correct |
25 |
Correct |
0 ms |
2216 KB |
Output is correct |
26 |
Correct |
0 ms |
2216 KB |
Output is correct |
27 |
Correct |
0 ms |
2216 KB |
Output is correct |
28 |
Correct |
0 ms |
2216 KB |
Output is correct |
29 |
Correct |
0 ms |
2216 KB |
Output is correct |
30 |
Correct |
0 ms |
2216 KB |
Output is correct |
31 |
Correct |
0 ms |
2216 KB |
Output is correct |
32 |
Correct |
0 ms |
2216 KB |
Output is correct |
33 |
Correct |
0 ms |
2216 KB |
Output is correct |
34 |
Correct |
0 ms |
2216 KB |
Output is correct |
35 |
Correct |
0 ms |
2216 KB |
Output is correct |
36 |
Correct |
0 ms |
2216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2216 KB |
Output is correct |
2 |
Correct |
0 ms |
2216 KB |
Output is correct |
3 |
Correct |
0 ms |
2216 KB |
Output is correct |
4 |
Correct |
0 ms |
2216 KB |
Output is correct |
5 |
Correct |
0 ms |
2216 KB |
Output is correct |
6 |
Correct |
0 ms |
2216 KB |
Output is correct |
7 |
Correct |
0 ms |
2216 KB |
Output is correct |
8 |
Correct |
0 ms |
2216 KB |
Output is correct |
9 |
Correct |
0 ms |
2216 KB |
Output is correct |
10 |
Correct |
0 ms |
2216 KB |
Output is correct |
11 |
Correct |
0 ms |
2216 KB |
Output is correct |
12 |
Correct |
0 ms |
2216 KB |
Output is correct |
13 |
Correct |
0 ms |
2216 KB |
Output is correct |
14 |
Correct |
0 ms |
2216 KB |
Output is correct |
15 |
Correct |
0 ms |
2216 KB |
Output is correct |
16 |
Correct |
0 ms |
2216 KB |
Output is correct |
17 |
Correct |
0 ms |
2216 KB |
Output is correct |
18 |
Correct |
0 ms |
2216 KB |
Output is correct |
19 |
Correct |
0 ms |
2216 KB |
Output is correct |
20 |
Correct |
0 ms |
2216 KB |
Output is correct |
21 |
Correct |
0 ms |
2216 KB |
Output is correct |
22 |
Correct |
0 ms |
2216 KB |
Output is correct |
23 |
Correct |
0 ms |
2216 KB |
Output is correct |
24 |
Correct |
0 ms |
2216 KB |
Output is correct |
25 |
Correct |
0 ms |
2216 KB |
Output is correct |
26 |
Correct |
0 ms |
2216 KB |
Output is correct |
27 |
Correct |
0 ms |
2216 KB |
Output is correct |
28 |
Correct |
0 ms |
2216 KB |
Output is correct |
29 |
Correct |
0 ms |
2216 KB |
Output is correct |
30 |
Correct |
0 ms |
2216 KB |
Output is correct |
31 |
Correct |
0 ms |
2216 KB |
Output is correct |
32 |
Correct |
0 ms |
2216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2216 KB |
Output is correct |
2 |
Correct |
0 ms |
2216 KB |
Output is correct |
3 |
Correct |
0 ms |
2216 KB |
Output is correct |
4 |
Correct |
0 ms |
2216 KB |
Output is correct |
5 |
Correct |
0 ms |
2216 KB |
Output is correct |
6 |
Correct |
0 ms |
2216 KB |
Output is correct |
7 |
Correct |
0 ms |
2216 KB |
Output is correct |
8 |
Correct |
0 ms |
2216 KB |
Output is correct |
9 |
Correct |
0 ms |
2216 KB |
Output is correct |
10 |
Correct |
0 ms |
2216 KB |
Output is correct |
11 |
Correct |
0 ms |
2216 KB |
Output is correct |
12 |
Correct |
0 ms |
2216 KB |
Output is correct |
13 |
Correct |
0 ms |
2216 KB |
Output is correct |
14 |
Correct |
0 ms |
2216 KB |
Output is correct |
15 |
Correct |
0 ms |
2216 KB |
Output is correct |
16 |
Correct |
0 ms |
2216 KB |
Output is correct |
17 |
Correct |
0 ms |
2216 KB |
Output is correct |
18 |
Correct |
0 ms |
2216 KB |
Output is correct |
19 |
Correct |
0 ms |
2216 KB |
Output is correct |
20 |
Correct |
0 ms |
2216 KB |
Output is correct |
21 |
Correct |
0 ms |
2216 KB |
Output is correct |
22 |
Correct |
0 ms |
2216 KB |
Output is correct |
23 |
Correct |
0 ms |
2216 KB |
Output is correct |
24 |
Correct |
0 ms |
2216 KB |
Output is correct |
25 |
Correct |
0 ms |
2216 KB |
Output is correct |
26 |
Correct |
0 ms |
2216 KB |
Output is correct |
27 |
Correct |
0 ms |
2216 KB |
Output is correct |
28 |
Correct |
0 ms |
2216 KB |
Output is correct |
29 |
Correct |
0 ms |
2216 KB |
Output is correct |
30 |
Correct |
0 ms |
2216 KB |
Output is correct |
31 |
Correct |
0 ms |
2216 KB |
Output is correct |
32 |
Correct |
0 ms |
2216 KB |
Output is correct |
33 |
Correct |
0 ms |
2216 KB |
Output is correct |
34 |
Correct |
0 ms |
2216 KB |
Output is correct |
35 |
Correct |
0 ms |
2216 KB |
Output is correct |
36 |
Correct |
0 ms |
2216 KB |
Output is correct |
37 |
Correct |
0 ms |
2216 KB |
Output is correct |
38 |
Correct |
0 ms |
2216 KB |
Output is correct |
39 |
Correct |
0 ms |
2216 KB |
Output is correct |
40 |
Correct |
0 ms |
2216 KB |
Output is correct |
41 |
Correct |
0 ms |
2216 KB |
Output is correct |
42 |
Correct |
0 ms |
2216 KB |
Output is correct |
43 |
Correct |
0 ms |
2216 KB |
Output is correct |
44 |
Correct |
0 ms |
2216 KB |
Output is correct |
45 |
Correct |
0 ms |
2216 KB |
Output is correct |
46 |
Correct |
0 ms |
2216 KB |
Output is correct |
47 |
Correct |
0 ms |
2216 KB |
Output is correct |
48 |
Correct |
0 ms |
2216 KB |
Output is correct |
49 |
Correct |
0 ms |
2216 KB |
Output is correct |
50 |
Correct |
0 ms |
2216 KB |
Output is correct |
51 |
Correct |
0 ms |
2216 KB |
Output is correct |
52 |
Correct |
0 ms |
2216 KB |
Output is correct |
53 |
Correct |
0 ms |
2216 KB |
Output is correct |
54 |
Correct |
0 ms |
2216 KB |
Output is correct |
55 |
Correct |
0 ms |
2216 KB |
Output is correct |
56 |
Correct |
0 ms |
2216 KB |
Output is correct |
57 |
Correct |
0 ms |
2216 KB |
Output is correct |
58 |
Correct |
0 ms |
2216 KB |
Output is correct |
59 |
Correct |
0 ms |
2216 KB |
Output is correct |
60 |
Correct |
0 ms |
2216 KB |
Output is correct |
61 |
Correct |
0 ms |
2216 KB |
Output is correct |
62 |
Correct |
0 ms |
2216 KB |
Output is correct |
63 |
Correct |
0 ms |
2216 KB |
Output is correct |
64 |
Correct |
6 ms |
2216 KB |
Output is correct |
65 |
Correct |
0 ms |
2216 KB |
Output is correct |
66 |
Correct |
3 ms |
2216 KB |
Output is correct |
67 |
Correct |
6 ms |
2216 KB |
Output is correct |
68 |
Correct |
9 ms |
2216 KB |
Output is correct |
69 |
Correct |
13 ms |
2216 KB |
Output is correct |
70 |
Correct |
13 ms |
2216 KB |
Output is correct |
71 |
Correct |
13 ms |
2216 KB |
Output is correct |
72 |
Correct |
13 ms |
2216 KB |
Output is correct |
73 |
Correct |
13 ms |
2216 KB |
Output is correct |
74 |
Correct |
13 ms |
2216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2216 KB |
Output is correct |
2 |
Correct |
0 ms |
2216 KB |
Output is correct |
3 |
Correct |
0 ms |
2216 KB |
Output is correct |
4 |
Correct |
0 ms |
2216 KB |
Output is correct |
5 |
Correct |
0 ms |
2216 KB |
Output is correct |
6 |
Correct |
0 ms |
2216 KB |
Output is correct |
7 |
Correct |
0 ms |
2216 KB |
Output is correct |
8 |
Correct |
0 ms |
2216 KB |
Output is correct |
9 |
Correct |
0 ms |
2216 KB |
Output is correct |
10 |
Correct |
0 ms |
2216 KB |
Output is correct |
11 |
Correct |
0 ms |
2216 KB |
Output is correct |
12 |
Correct |
0 ms |
2216 KB |
Output is correct |
13 |
Correct |
0 ms |
2216 KB |
Output is correct |
14 |
Correct |
0 ms |
2216 KB |
Output is correct |
15 |
Correct |
0 ms |
2216 KB |
Output is correct |
16 |
Correct |
0 ms |
2216 KB |
Output is correct |
17 |
Correct |
0 ms |
2216 KB |
Output is correct |
18 |
Correct |
0 ms |
2216 KB |
Output is correct |
19 |
Correct |
0 ms |
2216 KB |
Output is correct |
20 |
Correct |
0 ms |
2216 KB |
Output is correct |
21 |
Correct |
0 ms |
2216 KB |
Output is correct |
22 |
Correct |
0 ms |
2216 KB |
Output is correct |
23 |
Correct |
0 ms |
2216 KB |
Output is correct |
24 |
Correct |
0 ms |
2216 KB |
Output is correct |
25 |
Correct |
0 ms |
2216 KB |
Output is correct |
26 |
Correct |
0 ms |
2216 KB |
Output is correct |
27 |
Correct |
0 ms |
2216 KB |
Output is correct |
28 |
Correct |
0 ms |
2216 KB |
Output is correct |
29 |
Correct |
0 ms |
2216 KB |
Output is correct |
30 |
Correct |
0 ms |
2216 KB |
Output is correct |
31 |
Correct |
0 ms |
2216 KB |
Output is correct |
32 |
Correct |
0 ms |
2216 KB |
Output is correct |
33 |
Correct |
0 ms |
2216 KB |
Output is correct |
34 |
Correct |
0 ms |
2216 KB |
Output is correct |
35 |
Correct |
0 ms |
2216 KB |
Output is correct |
36 |
Correct |
0 ms |
2216 KB |
Output is correct |
37 |
Correct |
0 ms |
2216 KB |
Output is correct |
38 |
Correct |
0 ms |
2216 KB |
Output is correct |
39 |
Correct |
0 ms |
2216 KB |
Output is correct |
40 |
Correct |
0 ms |
2216 KB |
Output is correct |
41 |
Correct |
0 ms |
2216 KB |
Output is correct |
42 |
Correct |
0 ms |
2216 KB |
Output is correct |
43 |
Correct |
0 ms |
2216 KB |
Output is correct |
44 |
Correct |
0 ms |
2216 KB |
Output is correct |
45 |
Correct |
0 ms |
2216 KB |
Output is correct |
46 |
Correct |
0 ms |
2216 KB |
Output is correct |
47 |
Correct |
0 ms |
2216 KB |
Output is correct |
48 |
Correct |
0 ms |
2216 KB |
Output is correct |
49 |
Correct |
0 ms |
2216 KB |
Output is correct |
50 |
Correct |
0 ms |
2216 KB |
Output is correct |
51 |
Correct |
0 ms |
2216 KB |
Output is correct |
52 |
Correct |
9 ms |
2216 KB |
Output is correct |
53 |
Correct |
16 ms |
2216 KB |
Output is correct |
54 |
Correct |
33 ms |
2216 KB |
Output is correct |
55 |
Correct |
29 ms |
2216 KB |
Output is correct |
56 |
Correct |
123 ms |
2216 KB |
Output is correct |
57 |
Correct |
119 ms |
2216 KB |
Output is correct |
58 |
Correct |
116 ms |
2216 KB |
Output is correct |
59 |
Correct |
116 ms |
2216 KB |
Output is correct |
60 |
Correct |
126 ms |
2216 KB |
Output is correct |
61 |
Correct |
0 ms |
2216 KB |
Output is correct |
62 |
Correct |
16 ms |
2216 KB |
Output is correct |
63 |
Correct |
33 ms |
2216 KB |
Output is correct |
64 |
Correct |
29 ms |
2216 KB |
Output is correct |
65 |
Correct |
59 ms |
2216 KB |
Output is correct |
66 |
Correct |
93 ms |
2216 KB |
Output is correct |
67 |
Correct |
119 ms |
2216 KB |
Output is correct |
68 |
Correct |
126 ms |
2216 KB |
Output is correct |
69 |
Correct |
119 ms |
2216 KB |
Output is correct |