Submission #957885

# Submission time Handle Problem Language Result Execution time Memory
957885 2024-04-04T12:46:40 Z hocln Bali Sculptures (APIO15_sculpture) C++17
100 / 100
385 ms 1112 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(v) v.begin(), v.end()
#define logg(x) (31 - __builtin_clz(x))
#define llogg(x) (63 - __builtin_clzll(x))
#define mini(v) min_element(v.begin(), v.end())
#define maxi(v) max_element(v.begin(), v.end())
#define TIME cerr << double(clock() - st) / (double)CLOCKS_PER_SEC
#define sq(a) ((a)*(a))
#ifdef hocln
#include "deb.h"
#else
#define imie(...) ""
#define debug() cerr
#endif
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef long double ld;
typedef tuple<ll, ll, ll> triple;
typedef tuple<ll, ll, ll, ll, ll> five;
typedef unsigned long long ull;
const long long INF = 4e18;
const int inf = 2e9;
const int MN = 3e5 + 15;
const int MX = 2e6 + 15;
//const long long MOD = 1e9 + 7;
//const long long MOD = 998244353;
const long double PI = 3.141592653589793238462643383279502884197;
template<typename T, typename T2> bool chmax(T& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<typename T, typename T2> bool chmin(T& a, const T2& b) { return a > b ? a = b, 1 : 0; }
template<typename T> using vector2 = vector<vector<T>>;
const int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };
const int dy[] = { 1, -1, 0, 0 , 1, -1, 1, -1};
std::random_device rd;
std::mt19937 gen(rd());
ll random(ll low, ll high) { uniform_int_distribution<> dist(low, high); return dist(gen); }
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first;
    return is >> p.second;
}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    for (auto &i: v) os << i << ' ';
    return os;
}
int tc = 0;
// I hate cp
inline void solve_test() {
	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll>v(n+1);
	for(int i = 1;i <= n;i++) cin >> v[i];
	auto valid = [&](ll msk) {
		bitset<2002>dp[n+1];
		dp[0][0] = 1;
		for(int i = 1;i <= n;i++) {
			ll sum = 0;
			for(int j = i;j > 0;j--) {
				sum += v[j];
				if((sum& msk) != sum) continue;
				dp[i] |= dp[j-1] << 1;
			}
		}
		bool ok = false;
		for(int i = a;i <= b;i++) ok |= dp[n][i];
		return ok;
	};
	ll msk = 0;
	for(int i = 40;i >= 0;i--) {
		if(valid(msk ^ ((1LL << i) - 1))) continue;
		msk ^= 1LL << i;
	}
	cout << msk;
}

int main()
{
    //srand(chrono::steady_clock::now().time_since_epoch().count());
    //freopen("convention2.in", "r", stdin);
    //freopen("convention2.out", "w", stdout);
	//cout << "Case #" << tc << ": " << ans << '\n';
	//cout << fixed << setprecision(4);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--) {
		++tc;
        solve_test();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 464 KB Output is correct
20 Correct 1 ms 592 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 464 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 2 ms 344 KB Output is correct
31 Correct 2 ms 348 KB Output is correct
32 Correct 4 ms 468 KB Output is correct
33 Correct 3 ms 348 KB Output is correct
34 Correct 3 ms 344 KB Output is correct
35 Correct 2 ms 348 KB Output is correct
36 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 3 ms 348 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 3 ms 348 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 3 ms 348 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 4 ms 348 KB Output is correct
26 Correct 5 ms 476 KB Output is correct
27 Correct 7 ms 348 KB Output is correct
28 Correct 9 ms 488 KB Output is correct
29 Correct 9 ms 504 KB Output is correct
30 Correct 10 ms 348 KB Output is correct
31 Correct 8 ms 344 KB Output is correct
32 Correct 8 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 1 ms 600 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 2 ms 348 KB Output is correct
40 Correct 2 ms 468 KB Output is correct
41 Correct 2 ms 344 KB Output is correct
42 Correct 2 ms 348 KB Output is correct
43 Correct 3 ms 348 KB Output is correct
44 Correct 3 ms 348 KB Output is correct
45 Correct 2 ms 348 KB Output is correct
46 Correct 2 ms 344 KB Output is correct
47 Correct 2 ms 344 KB Output is correct
48 Correct 5 ms 344 KB Output is correct
49 Correct 5 ms 344 KB Output is correct
50 Correct 7 ms 484 KB Output is correct
51 Correct 9 ms 344 KB Output is correct
52 Correct 8 ms 344 KB Output is correct
53 Correct 9 ms 348 KB Output is correct
54 Correct 9 ms 348 KB Output is correct
55 Correct 8 ms 344 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 2 ms 348 KB Output is correct
58 Correct 2 ms 348 KB Output is correct
59 Correct 2 ms 484 KB Output is correct
60 Correct 2 ms 348 KB Output is correct
61 Correct 2 ms 348 KB Output is correct
62 Correct 3 ms 348 KB Output is correct
63 Correct 3 ms 348 KB Output is correct
64 Correct 8 ms 348 KB Output is correct
65 Correct 1 ms 344 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 2 ms 348 KB Output is correct
68 Correct 2 ms 348 KB Output is correct
69 Correct 2 ms 348 KB Output is correct
70 Correct 2 ms 348 KB Output is correct
71 Correct 2 ms 348 KB Output is correct
72 Correct 3 ms 344 KB Output is correct
73 Correct 3 ms 348 KB Output is correct
74 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 500 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 3 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 3 ms 412 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 4 ms 348 KB Output is correct
36 Correct 6 ms 348 KB Output is correct
37 Correct 7 ms 480 KB Output is correct
38 Correct 8 ms 348 KB Output is correct
39 Correct 8 ms 600 KB Output is correct
40 Correct 9 ms 348 KB Output is correct
41 Correct 10 ms 348 KB Output is correct
42 Correct 8 ms 344 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 2 ms 348 KB Output is correct
45 Correct 2 ms 348 KB Output is correct
46 Correct 2 ms 344 KB Output is correct
47 Correct 2 ms 348 KB Output is correct
48 Correct 2 ms 348 KB Output is correct
49 Correct 3 ms 348 KB Output is correct
50 Correct 3 ms 348 KB Output is correct
51 Correct 2 ms 348 KB Output is correct
52 Correct 42 ms 604 KB Output is correct
53 Correct 62 ms 600 KB Output is correct
54 Correct 114 ms 852 KB Output is correct
55 Correct 108 ms 700 KB Output is correct
56 Correct 322 ms 956 KB Output is correct
57 Correct 307 ms 856 KB Output is correct
58 Correct 217 ms 1112 KB Output is correct
59 Correct 218 ms 860 KB Output is correct
60 Correct 385 ms 980 KB Output is correct
61 Correct 4 ms 344 KB Output is correct
62 Correct 62 ms 604 KB Output is correct
63 Correct 111 ms 712 KB Output is correct
64 Correct 98 ms 604 KB Output is correct
65 Correct 174 ms 852 KB Output is correct
66 Correct 220 ms 860 KB Output is correct
67 Correct 306 ms 972 KB Output is correct
68 Correct 309 ms 984 KB Output is correct
69 Correct 267 ms 976 KB Output is correct