#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define clr(dp,i) memset(dp,i,sizeof(dp))
#define opt ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
tree_order_statistics_node_update> oset;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const long long mod = 1e9+7;
const ld pi = 3.14159265358979323846264338327950288;
//========================================
ll n, l, r, mx, a[2001], dp[101][101], ans;
ll h = (1LL << 50) - 1;
bool sol(int i, int j, ll T)
{
if(i == n && j != mx)
return 0;
else if(i != n && j == mx)
return 0;
else if(i == n && j == mx)
return 1;
ll &ret = dp[i][j];
if(ret != -1)
return ret;
ll sum = 0;
for(; i<n; i++)
{
sum += a[i];
ll enc = (sum^h);
bitset<50> b(enc);
bitset<50> c(T);
if((enc & T) == T && sol(i+1, j+1, T))
return dp[i][j] = 1;
}
return dp[i][j] = 0;
}
int main()
{
cin >> n >> l >> r;
for(int i=0; i<n; i++)
cin >> a[i];
for(int i=60; i>=0; i--)
{
for(int j=l; j<=r; j++)
{
clr(dp, -1);
mx = j;
if(sol(0, 0, (ans | (1LL << i))))
ans |= (1LL << i);
}
}
cout << (ans^h) << endl;
}
Compilation message
sculpture.cpp: In function 'bool sol(int, int, ll)':
sculpture.cpp:46:19: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
return dp[i][j] = 1;
~~~~~~~~~^~~
sculpture.cpp:48:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
return dp[i][j] = 0;
~~~~~~~~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
3 ms |
484 KB |
Output is correct |
5 |
Correct |
2 ms |
484 KB |
Output is correct |
6 |
Correct |
6 ms |
516 KB |
Output is correct |
7 |
Correct |
3 ms |
652 KB |
Output is correct |
8 |
Correct |
3 ms |
652 KB |
Output is correct |
9 |
Correct |
3 ms |
652 KB |
Output is correct |
10 |
Correct |
3 ms |
652 KB |
Output is correct |
11 |
Correct |
3 ms |
652 KB |
Output is correct |
12 |
Correct |
3 ms |
652 KB |
Output is correct |
13 |
Correct |
7 ms |
652 KB |
Output is correct |
14 |
Correct |
3 ms |
652 KB |
Output is correct |
15 |
Correct |
3 ms |
652 KB |
Output is correct |
16 |
Correct |
4 ms |
652 KB |
Output is correct |
17 |
Correct |
3 ms |
652 KB |
Output is correct |
18 |
Correct |
3 ms |
652 KB |
Output is correct |
19 |
Correct |
2 ms |
652 KB |
Output is correct |
20 |
Correct |
3 ms |
652 KB |
Output is correct |
21 |
Correct |
3 ms |
656 KB |
Output is correct |
22 |
Correct |
3 ms |
692 KB |
Output is correct |
23 |
Correct |
3 ms |
696 KB |
Output is correct |
24 |
Correct |
3 ms |
828 KB |
Output is correct |
25 |
Correct |
5 ms |
828 KB |
Output is correct |
26 |
Correct |
5 ms |
828 KB |
Output is correct |
27 |
Correct |
3 ms |
852 KB |
Output is correct |
28 |
Correct |
4 ms |
852 KB |
Output is correct |
29 |
Correct |
5 ms |
852 KB |
Output is correct |
30 |
Correct |
3 ms |
852 KB |
Output is correct |
31 |
Correct |
4 ms |
852 KB |
Output is correct |
32 |
Correct |
3 ms |
852 KB |
Output is correct |
33 |
Correct |
10 ms |
952 KB |
Output is correct |
34 |
Correct |
54 ms |
952 KB |
Output is correct |
35 |
Correct |
3 ms |
952 KB |
Output is correct |
36 |
Correct |
176 ms |
952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
952 KB |
Output is correct |
2 |
Correct |
3 ms |
952 KB |
Output is correct |
3 |
Correct |
2 ms |
952 KB |
Output is correct |
4 |
Correct |
3 ms |
952 KB |
Output is correct |
5 |
Correct |
2 ms |
952 KB |
Output is correct |
6 |
Correct |
7 ms |
952 KB |
Output is correct |
7 |
Correct |
4 ms |
952 KB |
Output is correct |
8 |
Correct |
3 ms |
952 KB |
Output is correct |
9 |
Correct |
3 ms |
952 KB |
Output is correct |
10 |
Correct |
3 ms |
952 KB |
Output is correct |
11 |
Correct |
4 ms |
952 KB |
Output is correct |
12 |
Correct |
5 ms |
952 KB |
Output is correct |
13 |
Correct |
7 ms |
952 KB |
Output is correct |
14 |
Correct |
3 ms |
952 KB |
Output is correct |
15 |
Correct |
2 ms |
952 KB |
Output is correct |
16 |
Correct |
3 ms |
952 KB |
Output is correct |
17 |
Correct |
3 ms |
952 KB |
Output is correct |
18 |
Correct |
3 ms |
952 KB |
Output is correct |
19 |
Correct |
4 ms |
952 KB |
Output is correct |
20 |
Correct |
4 ms |
952 KB |
Output is correct |
21 |
Correct |
3 ms |
972 KB |
Output is correct |
22 |
Correct |
4 ms |
980 KB |
Output is correct |
23 |
Correct |
5 ms |
980 KB |
Output is correct |
24 |
Correct |
3 ms |
980 KB |
Output is correct |
25 |
Correct |
4 ms |
1020 KB |
Output is correct |
26 |
Correct |
4 ms |
1020 KB |
Output is correct |
27 |
Correct |
7 ms |
1020 KB |
Output is correct |
28 |
Correct |
5 ms |
1020 KB |
Output is correct |
29 |
Correct |
4 ms |
1020 KB |
Output is correct |
30 |
Correct |
226 ms |
1024 KB |
Output is correct |
31 |
Execution timed out |
1096 ms |
1024 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1024 KB |
Output is correct |
2 |
Correct |
4 ms |
1024 KB |
Output is correct |
3 |
Correct |
2 ms |
1024 KB |
Output is correct |
4 |
Correct |
3 ms |
1024 KB |
Output is correct |
5 |
Correct |
2 ms |
1024 KB |
Output is correct |
6 |
Correct |
7 ms |
1024 KB |
Output is correct |
7 |
Correct |
3 ms |
1024 KB |
Output is correct |
8 |
Correct |
4 ms |
1024 KB |
Output is correct |
9 |
Correct |
3 ms |
1028 KB |
Output is correct |
10 |
Correct |
3 ms |
1028 KB |
Output is correct |
11 |
Correct |
2 ms |
1028 KB |
Output is correct |
12 |
Correct |
3 ms |
1172 KB |
Output is correct |
13 |
Correct |
7 ms |
1172 KB |
Output is correct |
14 |
Correct |
7 ms |
1172 KB |
Output is correct |
15 |
Correct |
5 ms |
1172 KB |
Output is correct |
16 |
Correct |
4 ms |
1172 KB |
Output is correct |
17 |
Correct |
303 ms |
1172 KB |
Output is correct |
18 |
Execution timed out |
1077 ms |
1172 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1172 KB |
Output is correct |
2 |
Correct |
3 ms |
1172 KB |
Output is correct |
3 |
Correct |
3 ms |
1172 KB |
Output is correct |
4 |
Correct |
3 ms |
1172 KB |
Output is correct |
5 |
Correct |
2 ms |
1172 KB |
Output is correct |
6 |
Correct |
6 ms |
1172 KB |
Output is correct |
7 |
Correct |
3 ms |
1172 KB |
Output is correct |
8 |
Correct |
4 ms |
1172 KB |
Output is correct |
9 |
Correct |
4 ms |
1172 KB |
Output is correct |
10 |
Correct |
4 ms |
1172 KB |
Output is correct |
11 |
Correct |
2 ms |
1172 KB |
Output is correct |
12 |
Correct |
3 ms |
1172 KB |
Output is correct |
13 |
Correct |
7 ms |
1172 KB |
Output is correct |
14 |
Correct |
3 ms |
1172 KB |
Output is correct |
15 |
Correct |
2 ms |
1172 KB |
Output is correct |
16 |
Correct |
4 ms |
1172 KB |
Output is correct |
17 |
Correct |
3 ms |
1172 KB |
Output is correct |
18 |
Correct |
3 ms |
1172 KB |
Output is correct |
19 |
Correct |
3 ms |
1172 KB |
Output is correct |
20 |
Correct |
2 ms |
1172 KB |
Output is correct |
21 |
Correct |
4 ms |
1172 KB |
Output is correct |
22 |
Correct |
4 ms |
1172 KB |
Output is correct |
23 |
Correct |
3 ms |
1172 KB |
Output is correct |
24 |
Correct |
3 ms |
1172 KB |
Output is correct |
25 |
Correct |
4 ms |
1172 KB |
Output is correct |
26 |
Correct |
4 ms |
1192 KB |
Output is correct |
27 |
Correct |
3 ms |
1192 KB |
Output is correct |
28 |
Correct |
4 ms |
1192 KB |
Output is correct |
29 |
Correct |
7 ms |
1192 KB |
Output is correct |
30 |
Correct |
4 ms |
1192 KB |
Output is correct |
31 |
Correct |
4 ms |
1192 KB |
Output is correct |
32 |
Correct |
3 ms |
1192 KB |
Output is correct |
33 |
Correct |
12 ms |
1192 KB |
Output is correct |
34 |
Correct |
57 ms |
1236 KB |
Output is correct |
35 |
Correct |
4 ms |
1236 KB |
Output is correct |
36 |
Correct |
157 ms |
1244 KB |
Output is correct |
37 |
Correct |
8 ms |
1244 KB |
Output is correct |
38 |
Correct |
5 ms |
1244 KB |
Output is correct |
39 |
Correct |
4 ms |
1244 KB |
Output is correct |
40 |
Correct |
230 ms |
1316 KB |
Output is correct |
41 |
Execution timed out |
1084 ms |
1316 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1316 KB |
Output is correct |
2 |
Correct |
4 ms |
1316 KB |
Output is correct |
3 |
Correct |
2 ms |
1316 KB |
Output is correct |
4 |
Correct |
3 ms |
1316 KB |
Output is correct |
5 |
Correct |
2 ms |
1316 KB |
Output is correct |
6 |
Correct |
6 ms |
1316 KB |
Output is correct |
7 |
Correct |
4 ms |
1316 KB |
Output is correct |
8 |
Correct |
3 ms |
1316 KB |
Output is correct |
9 |
Correct |
3 ms |
1316 KB |
Output is correct |
10 |
Correct |
3 ms |
1316 KB |
Output is correct |
11 |
Correct |
2 ms |
1316 KB |
Output is correct |
12 |
Correct |
3 ms |
1316 KB |
Output is correct |
13 |
Correct |
7 ms |
1316 KB |
Output is correct |
14 |
Correct |
4 ms |
1316 KB |
Output is correct |
15 |
Correct |
5 ms |
1320 KB |
Output is correct |
16 |
Correct |
6 ms |
1320 KB |
Output is correct |
17 |
Correct |
3 ms |
1320 KB |
Output is correct |
18 |
Correct |
6 ms |
1320 KB |
Output is correct |
19 |
Correct |
2 ms |
1320 KB |
Output is correct |
20 |
Correct |
10 ms |
1344 KB |
Output is correct |
21 |
Correct |
52 ms |
1424 KB |
Output is correct |
22 |
Correct |
3 ms |
1424 KB |
Output is correct |
23 |
Correct |
157 ms |
1488 KB |
Output is correct |
24 |
Correct |
8 ms |
1488 KB |
Output is correct |
25 |
Correct |
6 ms |
1488 KB |
Output is correct |
26 |
Correct |
5 ms |
1488 KB |
Output is correct |
27 |
Correct |
224 ms |
1488 KB |
Output is correct |
28 |
Execution timed out |
1074 ms |
1488 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |