답안 #44999

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44999 2018-04-10T11:54:27 Z Mamnoon_Siam Bali Sculptures (APIO15_sculpture) C++17
71 / 100
156 ms 4888 KB
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")

#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];
bool dp[maxn][maxn];

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

bool fek() {
	int temp[maxn];
	temp[0] = 0;
	for(int i=1; i<=n; i++) {
		temp[i] = 987654321;
		int s = 0;
		for(int j=i; j>=1; j--) {
			s += a[j];
			if((s & mask) == s) {
				temp[i] = min(temp[i], temp[j-1] + 1);
			}
		}
	} return temp[n] <= B;
}

bool can() {
	if(A == 1) return fek();
	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:17:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
  ^~
sculpture.cpp:17: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;
                          ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 640 KB Output is correct
9 Correct 2 ms 644 KB Output is correct
10 Correct 2 ms 644 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 2 ms 664 KB Output is correct
13 Correct 2 ms 668 KB Output is correct
14 Correct 13 ms 4532 KB Output is correct
15 Correct 14 ms 4536 KB Output is correct
16 Correct 13 ms 4540 KB Output is correct
17 Correct 13 ms 4544 KB Output is correct
18 Correct 16 ms 4552 KB Output is correct
19 Correct 13 ms 4556 KB Output is correct
20 Correct 14 ms 4556 KB Output is correct
21 Correct 16 ms 4560 KB Output is correct
22 Correct 13 ms 4612 KB Output is correct
23 Correct 13 ms 4612 KB Output is correct
24 Correct 14 ms 4612 KB Output is correct
25 Correct 15 ms 4612 KB Output is correct
26 Correct 13 ms 4612 KB Output is correct
27 Correct 2 ms 4612 KB Output is correct
28 Correct 2 ms 4612 KB Output is correct
29 Correct 2 ms 4612 KB Output is correct
30 Correct 2 ms 4612 KB Output is correct
31 Correct 2 ms 4612 KB Output is correct
32 Correct 2 ms 4612 KB Output is correct
33 Correct 2 ms 4612 KB Output is correct
34 Correct 3 ms 4612 KB Output is correct
35 Correct 2 ms 4612 KB Output is correct
36 Correct 2 ms 4612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4612 KB Output is correct
2 Correct 2 ms 4612 KB Output is correct
3 Correct 2 ms 4612 KB Output is correct
4 Correct 2 ms 4612 KB Output is correct
5 Correct 2 ms 4612 KB Output is correct
6 Correct 2 ms 4612 KB Output is correct
7 Correct 3 ms 4612 KB Output is correct
8 Correct 2 ms 4612 KB Output is correct
9 Correct 2 ms 4612 KB Output is correct
10 Correct 2 ms 4612 KB Output is correct
11 Correct 2 ms 4612 KB Output is correct
12 Correct 2 ms 4612 KB Output is correct
13 Correct 2 ms 4612 KB Output is correct
14 Correct 13 ms 4676 KB Output is correct
15 Correct 15 ms 4684 KB Output is correct
16 Correct 13 ms 4692 KB Output is correct
17 Correct 13 ms 4756 KB Output is correct
18 Correct 13 ms 4756 KB Output is correct
19 Correct 13 ms 4756 KB Output is correct
20 Correct 13 ms 4756 KB Output is correct
21 Correct 13 ms 4756 KB Output is correct
22 Correct 14 ms 4756 KB Output is correct
23 Correct 13 ms 4756 KB Output is correct
24 Correct 14 ms 4756 KB Output is correct
25 Correct 15 ms 4756 KB Output is correct
26 Correct 13 ms 4816 KB Output is correct
27 Correct 2 ms 4816 KB Output is correct
28 Correct 2 ms 4816 KB Output is correct
29 Correct 2 ms 4816 KB Output is correct
30 Correct 2 ms 4816 KB Output is correct
31 Correct 2 ms 4816 KB Output is correct
32 Correct 2 ms 4816 KB Output is correct
33 Correct 2 ms 4816 KB Output is correct
34 Correct 2 ms 4816 KB Output is correct
35 Correct 2 ms 4816 KB Output is correct
36 Correct 2 ms 4816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4816 KB Output is correct
2 Correct 2 ms 4816 KB Output is correct
3 Correct 2 ms 4816 KB Output is correct
4 Correct 2 ms 4816 KB Output is correct
5 Correct 2 ms 4816 KB Output is correct
6 Correct 2 ms 4816 KB Output is correct
7 Correct 2 ms 4816 KB Output is correct
8 Correct 2 ms 4816 KB Output is correct
9 Correct 2 ms 4816 KB Output is correct
10 Correct 2 ms 4816 KB Output is correct
11 Correct 2 ms 4816 KB Output is correct
12 Correct 2 ms 4816 KB Output is correct
13 Correct 2 ms 4816 KB Output is correct
14 Correct 2 ms 4816 KB Output is correct
15 Correct 2 ms 4816 KB Output is correct
16 Correct 2 ms 4816 KB Output is correct
17 Correct 2 ms 4816 KB Output is correct
18 Correct 3 ms 4816 KB Output is correct
19 Correct 2 ms 4816 KB Output is correct
20 Correct 2 ms 4816 KB Output is correct
21 Correct 3 ms 4816 KB Output is correct
22 Correct 2 ms 4816 KB Output is correct
23 Correct 2 ms 4816 KB Output is correct
24 Correct 2 ms 4816 KB Output is correct
25 Correct 2 ms 4816 KB Output is correct
26 Correct 2 ms 4816 KB Output is correct
27 Correct 2 ms 4816 KB Output is correct
28 Correct 3 ms 4816 KB Output is correct
29 Correct 2 ms 4816 KB Output is correct
30 Correct 2 ms 4816 KB Output is correct
31 Correct 2 ms 4816 KB Output is correct
32 Correct 2 ms 4816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4816 KB Output is correct
2 Correct 2 ms 4816 KB Output is correct
3 Correct 2 ms 4816 KB Output is correct
4 Correct 2 ms 4816 KB Output is correct
5 Correct 2 ms 4816 KB Output is correct
6 Correct 2 ms 4816 KB Output is correct
7 Correct 2 ms 4816 KB Output is correct
8 Correct 2 ms 4816 KB Output is correct
9 Correct 2 ms 4816 KB Output is correct
10 Correct 2 ms 4816 KB Output is correct
11 Correct 2 ms 4816 KB Output is correct
12 Correct 2 ms 4816 KB Output is correct
13 Correct 2 ms 4816 KB Output is correct
14 Correct 15 ms 4888 KB Output is correct
15 Correct 13 ms 4888 KB Output is correct
16 Correct 13 ms 4888 KB Output is correct
17 Correct 13 ms 4888 KB Output is correct
18 Correct 13 ms 4888 KB Output is correct
19 Correct 13 ms 4888 KB Output is correct
20 Correct 15 ms 4888 KB Output is correct
21 Correct 14 ms 4888 KB Output is correct
22 Correct 13 ms 4888 KB Output is correct
23 Correct 14 ms 4888 KB Output is correct
24 Correct 13 ms 4888 KB Output is correct
25 Correct 14 ms 4888 KB Output is correct
26 Correct 14 ms 4888 KB Output is correct
27 Correct 2 ms 4888 KB Output is correct
28 Correct 2 ms 4888 KB Output is correct
29 Correct 2 ms 4888 KB Output is correct
30 Correct 2 ms 4888 KB Output is correct
31 Correct 2 ms 4888 KB Output is correct
32 Correct 2 ms 4888 KB Output is correct
33 Correct 2 ms 4888 KB Output is correct
34 Correct 2 ms 4888 KB Output is correct
35 Correct 2 ms 4888 KB Output is correct
36 Correct 2 ms 4888 KB Output is correct
37 Correct 2 ms 4888 KB Output is correct
38 Correct 2 ms 4888 KB Output is correct
39 Correct 2 ms 4888 KB Output is correct
40 Correct 2 ms 4888 KB Output is correct
41 Correct 2 ms 4888 KB Output is correct
42 Correct 3 ms 4888 KB Output is correct
43 Correct 3 ms 4888 KB Output is correct
44 Correct 2 ms 4888 KB Output is correct
45 Correct 2 ms 4888 KB Output is correct
46 Correct 3 ms 4888 KB Output is correct
47 Correct 2 ms 4888 KB Output is correct
48 Correct 2 ms 4888 KB Output is correct
49 Correct 2 ms 4888 KB Output is correct
50 Correct 2 ms 4888 KB Output is correct
51 Correct 3 ms 4888 KB Output is correct
52 Correct 2 ms 4888 KB Output is correct
53 Correct 2 ms 4888 KB Output is correct
54 Correct 3 ms 4888 KB Output is correct
55 Correct 2 ms 4888 KB Output is correct
56 Correct 2 ms 4888 KB Output is correct
57 Correct 2 ms 4888 KB Output is correct
58 Correct 2 ms 4888 KB Output is correct
59 Correct 2 ms 4888 KB Output is correct
60 Correct 2 ms 4888 KB Output is correct
61 Correct 3 ms 4888 KB Output is correct
62 Correct 3 ms 4888 KB Output is correct
63 Correct 3 ms 4888 KB Output is correct
64 Correct 34 ms 4888 KB Output is correct
65 Correct 21 ms 4888 KB Output is correct
66 Correct 19 ms 4888 KB Output is correct
67 Correct 23 ms 4888 KB Output is correct
68 Correct 37 ms 4888 KB Output is correct
69 Correct 55 ms 4888 KB Output is correct
70 Correct 50 ms 4888 KB Output is correct
71 Correct 41 ms 4888 KB Output is correct
72 Correct 43 ms 4888 KB Output is correct
73 Correct 36 ms 4888 KB Output is correct
74 Correct 37 ms 4888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4888 KB Output is correct
2 Correct 2 ms 4888 KB Output is correct
3 Correct 2 ms 4888 KB Output is correct
4 Correct 2 ms 4888 KB Output is correct
5 Correct 2 ms 4888 KB Output is correct
6 Correct 2 ms 4888 KB Output is correct
7 Correct 2 ms 4888 KB Output is correct
8 Correct 3 ms 4888 KB Output is correct
9 Correct 2 ms 4888 KB Output is correct
10 Correct 2 ms 4888 KB Output is correct
11 Correct 2 ms 4888 KB Output is correct
12 Correct 2 ms 4888 KB Output is correct
13 Correct 2 ms 4888 KB Output is correct
14 Correct 2 ms 4888 KB Output is correct
15 Correct 2 ms 4888 KB Output is correct
16 Correct 2 ms 4888 KB Output is correct
17 Correct 2 ms 4888 KB Output is correct
18 Correct 2 ms 4888 KB Output is correct
19 Correct 2 ms 4888 KB Output is correct
20 Correct 2 ms 4888 KB Output is correct
21 Correct 2 ms 4888 KB Output is correct
22 Correct 2 ms 4888 KB Output is correct
23 Correct 2 ms 4888 KB Output is correct
24 Correct 2 ms 4888 KB Output is correct
25 Correct 2 ms 4888 KB Output is correct
26 Correct 2 ms 4888 KB Output is correct
27 Correct 2 ms 4888 KB Output is correct
28 Correct 2 ms 4888 KB Output is correct
29 Correct 3 ms 4888 KB Output is correct
30 Correct 2 ms 4888 KB Output is correct
31 Correct 2 ms 4888 KB Output is correct
32 Correct 2 ms 4888 KB Output is correct
33 Correct 3 ms 4888 KB Output is correct
34 Correct 2 ms 4888 KB Output is correct
35 Correct 3 ms 4888 KB Output is correct
36 Correct 2 ms 4888 KB Output is correct
37 Correct 3 ms 4888 KB Output is correct
38 Correct 2 ms 4888 KB Output is correct
39 Correct 3 ms 4888 KB Output is correct
40 Correct 3 ms 4888 KB Output is correct
41 Correct 3 ms 4888 KB Output is correct
42 Correct 3 ms 4888 KB Output is correct
43 Correct 2 ms 4888 KB Output is correct
44 Correct 2 ms 4888 KB Output is correct
45 Correct 2 ms 4888 KB Output is correct
46 Correct 3 ms 4888 KB Output is correct
47 Correct 2 ms 4888 KB Output is correct
48 Correct 3 ms 4888 KB Output is correct
49 Correct 3 ms 4888 KB Output is correct
50 Correct 2 ms 4888 KB Output is correct
51 Correct 3 ms 4888 KB Output is correct
52 Correct 12 ms 4888 KB Output is correct
53 Correct 13 ms 4888 KB Output is correct
54 Correct 27 ms 4888 KB Output is correct
55 Correct 22 ms 4888 KB Output is correct
56 Correct 89 ms 4888 KB Output is correct
57 Correct 70 ms 4888 KB Output is correct
58 Correct 70 ms 4888 KB Output is correct
59 Correct 67 ms 4888 KB Output is correct
60 Incorrect 156 ms 4888 KB Output isn't correct
61 Halted 0 ms 0 KB -