Submission #44935

# Submission time Handle Problem Language Result Execution time Memory
44935 2018-04-09T17:47:40 Z Mamnoon_Siam Bali Sculptures (APIO15_sculpture) C++17
71 / 100
1000 ms 32248 KB
#include <bits/stdc++.h>
using namespace std;

#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define MEMSET(a,val) memset(a, val, sizeof a)
#define PB push_back
#define endl '\n'
#define int long long

inline int myrand(int l, int r) {
	int ret = rand(); ret <<= 15; ret ^= rand();
	if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
	return ret;
}
template <typename F, typename S>
ostream& operator << (ostream& os, const pair< F, S>& p) {
    return os<<"(" <<p.first<<", "<<p.second<<")"; }

typedef pair<int, int> ii;
template<typename T> using min_pq =
	priority_queue<T, vector<T>, greater<T> >;

//int dx[] = {-1, +0, +1, +0};
//int dy[] = {+0, +1, +0, -1};

const int maxn = 2002;

int n, A, B;
int a[maxn];
int dp[maxn][maxn];

int mask = (1LL << 40) - 1;

bool can() {
	MEMSET(dp, 0);
	dp[0][0] = 1;
	for(int k=1; k<=n; k++) {
		for(int i=1; i<=n; i++) {
			int s = 0;
			for(int j=i-1; j>=0; j--) {
				s += a[j+1];
				dp[k][i] |= ((s & mask) == s and dp[k-1][j]);
			}
		}
	}
	bool ret = false;
	for(int i=A; i<=B; i++) {
		ret |= dp[i][n];
	} return ret;
}

int32_t main () {
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin>>n>>A>>B;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
	}
	for(int i=39; i>=0; i--) {
		mask ^= (1LL << i);
		if(!can()) mask ^= (1LL << i);
	}
	cout << mask << endl;
	return 0;
}

Compilation message

sculpture.cpp: In function 'long long int myrand(long long int, long long int)':
sculpture.cpp:14:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
  ^~
sculpture.cpp:14:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
                          ^~~
# Verdict Execution time Memory Grader output
1 Correct 267 ms 31864 KB Output is correct
2 Correct 266 ms 31864 KB Output is correct
3 Correct 264 ms 31904 KB Output is correct
4 Correct 266 ms 31956 KB Output is correct
5 Correct 263 ms 31956 KB Output is correct
6 Correct 303 ms 31956 KB Output is correct
7 Correct 270 ms 32016 KB Output is correct
8 Correct 280 ms 32016 KB Output is correct
9 Correct 276 ms 32016 KB Output is correct
10 Correct 271 ms 32016 KB Output is correct
11 Correct 292 ms 32016 KB Output is correct
12 Correct 283 ms 32016 KB Output is correct
13 Correct 274 ms 32020 KB Output is correct
14 Correct 270 ms 32020 KB Output is correct
15 Correct 272 ms 32020 KB Output is correct
16 Correct 271 ms 32020 KB Output is correct
17 Correct 274 ms 32020 KB Output is correct
18 Correct 277 ms 32020 KB Output is correct
19 Correct 276 ms 32032 KB Output is correct
20 Correct 279 ms 32032 KB Output is correct
21 Correct 271 ms 32032 KB Output is correct
22 Correct 278 ms 32040 KB Output is correct
23 Correct 267 ms 32040 KB Output is correct
24 Correct 282 ms 32056 KB Output is correct
25 Correct 274 ms 32056 KB Output is correct
26 Correct 268 ms 32056 KB Output is correct
27 Correct 279 ms 32056 KB Output is correct
28 Correct 265 ms 32056 KB Output is correct
29 Correct 287 ms 32056 KB Output is correct
30 Correct 277 ms 32056 KB Output is correct
31 Correct 271 ms 32056 KB Output is correct
32 Correct 261 ms 32056 KB Output is correct
33 Correct 274 ms 32100 KB Output is correct
34 Correct 267 ms 32100 KB Output is correct
35 Correct 268 ms 32100 KB Output is correct
36 Correct 275 ms 32100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 269 ms 32100 KB Output is correct
2 Correct 273 ms 32100 KB Output is correct
3 Correct 270 ms 32100 KB Output is correct
4 Correct 268 ms 32100 KB Output is correct
5 Correct 273 ms 32100 KB Output is correct
6 Correct 274 ms 32100 KB Output is correct
7 Correct 267 ms 32100 KB Output is correct
8 Correct 271 ms 32108 KB Output is correct
9 Correct 279 ms 32108 KB Output is correct
10 Correct 265 ms 32108 KB Output is correct
11 Correct 267 ms 32108 KB Output is correct
12 Correct 275 ms 32108 KB Output is correct
13 Correct 269 ms 32108 KB Output is correct
14 Correct 269 ms 32124 KB Output is correct
15 Correct 270 ms 32124 KB Output is correct
16 Correct 276 ms 32124 KB Output is correct
17 Correct 278 ms 32124 KB Output is correct
18 Correct 280 ms 32124 KB Output is correct
19 Correct 267 ms 32124 KB Output is correct
20 Correct 272 ms 32124 KB Output is correct
21 Correct 278 ms 32124 KB Output is correct
22 Correct 283 ms 32124 KB Output is correct
23 Correct 277 ms 32124 KB Output is correct
24 Correct 287 ms 32124 KB Output is correct
25 Correct 298 ms 32124 KB Output is correct
26 Correct 308 ms 32124 KB Output is correct
27 Correct 273 ms 32124 KB Output is correct
28 Correct 278 ms 32124 KB Output is correct
29 Correct 290 ms 32124 KB Output is correct
30 Correct 287 ms 32124 KB Output is correct
31 Correct 285 ms 32124 KB Output is correct
32 Correct 297 ms 32124 KB Output is correct
33 Correct 279 ms 32124 KB Output is correct
34 Correct 281 ms 32124 KB Output is correct
35 Correct 288 ms 32124 KB Output is correct
36 Correct 270 ms 32124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 265 ms 32124 KB Output is correct
2 Correct 268 ms 32124 KB Output is correct
3 Correct 275 ms 32124 KB Output is correct
4 Correct 273 ms 32124 KB Output is correct
5 Correct 277 ms 32124 KB Output is correct
6 Correct 279 ms 32124 KB Output is correct
7 Correct 273 ms 32124 KB Output is correct
8 Correct 266 ms 32124 KB Output is correct
9 Correct 273 ms 32124 KB Output is correct
10 Correct 275 ms 32124 KB Output is correct
11 Correct 287 ms 32124 KB Output is correct
12 Correct 270 ms 32124 KB Output is correct
13 Correct 270 ms 32124 KB Output is correct
14 Correct 274 ms 32124 KB Output is correct
15 Correct 271 ms 32124 KB Output is correct
16 Correct 277 ms 32124 KB Output is correct
17 Correct 274 ms 32124 KB Output is correct
18 Correct 276 ms 32124 KB Output is correct
19 Correct 278 ms 32124 KB Output is correct
20 Correct 276 ms 32236 KB Output is correct
21 Correct 280 ms 32236 KB Output is correct
22 Correct 275 ms 32236 KB Output is correct
23 Correct 278 ms 32236 KB Output is correct
24 Correct 275 ms 32236 KB Output is correct
25 Correct 276 ms 32236 KB Output is correct
26 Correct 288 ms 32236 KB Output is correct
27 Correct 298 ms 32236 KB Output is correct
28 Correct 320 ms 32236 KB Output is correct
29 Correct 307 ms 32248 KB Output is correct
30 Correct 318 ms 32248 KB Output is correct
31 Correct 302 ms 32248 KB Output is correct
32 Correct 310 ms 32248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 272 ms 32248 KB Output is correct
2 Correct 279 ms 32248 KB Output is correct
3 Correct 271 ms 32248 KB Output is correct
4 Correct 309 ms 32248 KB Output is correct
5 Correct 274 ms 32248 KB Output is correct
6 Correct 272 ms 32248 KB Output is correct
7 Correct 277 ms 32248 KB Output is correct
8 Correct 274 ms 32248 KB Output is correct
9 Correct 270 ms 32248 KB Output is correct
10 Correct 270 ms 32248 KB Output is correct
11 Correct 269 ms 32248 KB Output is correct
12 Correct 268 ms 32248 KB Output is correct
13 Correct 274 ms 32248 KB Output is correct
14 Correct 271 ms 32248 KB Output is correct
15 Correct 267 ms 32248 KB Output is correct
16 Correct 263 ms 32248 KB Output is correct
17 Correct 270 ms 32248 KB Output is correct
18 Correct 266 ms 32248 KB Output is correct
19 Correct 266 ms 32248 KB Output is correct
20 Correct 286 ms 32248 KB Output is correct
21 Correct 303 ms 32248 KB Output is correct
22 Correct 266 ms 32248 KB Output is correct
23 Correct 302 ms 32248 KB Output is correct
24 Correct 302 ms 32248 KB Output is correct
25 Correct 323 ms 32248 KB Output is correct
26 Correct 307 ms 32248 KB Output is correct
27 Correct 303 ms 32248 KB Output is correct
28 Correct 321 ms 32248 KB Output is correct
29 Correct 311 ms 32248 KB Output is correct
30 Correct 297 ms 32248 KB Output is correct
31 Correct 317 ms 32248 KB Output is correct
32 Correct 315 ms 32248 KB Output is correct
33 Correct 307 ms 32248 KB Output is correct
34 Correct 308 ms 32248 KB Output is correct
35 Correct 308 ms 32248 KB Output is correct
36 Correct 310 ms 32248 KB Output is correct
37 Correct 304 ms 32248 KB Output is correct
38 Correct 314 ms 32248 KB Output is correct
39 Correct 310 ms 32248 KB Output is correct
40 Correct 314 ms 32248 KB Output is correct
41 Correct 318 ms 32248 KB Output is correct
42 Correct 329 ms 32248 KB Output is correct
43 Correct 310 ms 32248 KB Output is correct
44 Correct 274 ms 32248 KB Output is correct
45 Correct 263 ms 32248 KB Output is correct
46 Correct 314 ms 32248 KB Output is correct
47 Correct 318 ms 32248 KB Output is correct
48 Correct 339 ms 32248 KB Output is correct
49 Correct 355 ms 32248 KB Output is correct
50 Correct 351 ms 32248 KB Output is correct
51 Correct 354 ms 32248 KB Output is correct
52 Correct 359 ms 32248 KB Output is correct
53 Correct 351 ms 32248 KB Output is correct
54 Correct 350 ms 32248 KB Output is correct
55 Correct 350 ms 32248 KB Output is correct
56 Correct 308 ms 32248 KB Output is correct
57 Correct 347 ms 32248 KB Output is correct
58 Correct 332 ms 32248 KB Output is correct
59 Correct 293 ms 32248 KB Output is correct
60 Correct 292 ms 32248 KB Output is correct
61 Correct 308 ms 32248 KB Output is correct
62 Correct 289 ms 32248 KB Output is correct
63 Correct 297 ms 32248 KB Output is correct
64 Correct 293 ms 32248 KB Output is correct
65 Correct 275 ms 32248 KB Output is correct
66 Correct 283 ms 32248 KB Output is correct
67 Correct 284 ms 32248 KB Output is correct
68 Correct 290 ms 32248 KB Output is correct
69 Correct 332 ms 32248 KB Output is correct
70 Correct 349 ms 32248 KB Output is correct
71 Correct 357 ms 32248 KB Output is correct
72 Correct 349 ms 32248 KB Output is correct
73 Correct 320 ms 32248 KB Output is correct
74 Correct 341 ms 32248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 318 ms 32248 KB Output is correct
2 Correct 296 ms 32248 KB Output is correct
3 Correct 317 ms 32248 KB Output is correct
4 Correct 313 ms 32248 KB Output is correct
5 Correct 317 ms 32248 KB Output is correct
6 Correct 319 ms 32248 KB Output is correct
7 Correct 276 ms 32248 KB Output is correct
8 Correct 281 ms 32248 KB Output is correct
9 Correct 313 ms 32248 KB Output is correct
10 Correct 310 ms 32248 KB Output is correct
11 Correct 302 ms 32248 KB Output is correct
12 Correct 319 ms 32248 KB Output is correct
13 Correct 305 ms 32248 KB Output is correct
14 Correct 329 ms 32248 KB Output is correct
15 Correct 314 ms 32248 KB Output is correct
16 Correct 307 ms 32248 KB Output is correct
17 Correct 311 ms 32248 KB Output is correct
18 Correct 323 ms 32248 KB Output is correct
19 Correct 271 ms 32248 KB Output is correct
20 Correct 271 ms 32248 KB Output is correct
21 Correct 269 ms 32248 KB Output is correct
22 Correct 278 ms 32248 KB Output is correct
23 Correct 275 ms 32248 KB Output is correct
24 Correct 285 ms 32248 KB Output is correct
25 Correct 263 ms 32248 KB Output is correct
26 Correct 252 ms 32248 KB Output is correct
27 Correct 264 ms 32248 KB Output is correct
28 Correct 272 ms 32248 KB Output is correct
29 Correct 278 ms 32248 KB Output is correct
30 Correct 297 ms 32248 KB Output is correct
31 Correct 276 ms 32248 KB Output is correct
32 Correct 280 ms 32248 KB Output is correct
33 Correct 272 ms 32248 KB Output is correct
34 Correct 276 ms 32248 KB Output is correct
35 Correct 282 ms 32248 KB Output is correct
36 Correct 296 ms 32248 KB Output is correct
37 Correct 297 ms 32248 KB Output is correct
38 Correct 332 ms 32248 KB Output is correct
39 Correct 332 ms 32248 KB Output is correct
40 Correct 360 ms 32248 KB Output is correct
41 Correct 344 ms 32248 KB Output is correct
42 Correct 345 ms 32248 KB Output is correct
43 Correct 322 ms 32248 KB Output is correct
44 Correct 337 ms 32248 KB Output is correct
45 Correct 350 ms 32248 KB Output is correct
46 Correct 346 ms 32248 KB Output is correct
47 Correct 351 ms 32248 KB Output is correct
48 Correct 361 ms 32248 KB Output is correct
49 Correct 357 ms 32248 KB Output is correct
50 Correct 353 ms 32248 KB Output is correct
51 Correct 374 ms 32248 KB Output is correct
52 Execution timed out 1079 ms 32248 KB Time limit exceeded
53 Halted 0 ms 0 KB -