답안 #44936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44936 2018-04-09T17:48:52 Z Mamnoon_Siam Bali Sculptures (APIO15_sculpture) C++17
71 / 100
1000 ms 4724 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];
bool 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;
                          ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4216 KB Output is correct
2 Correct 13 ms 4216 KB Output is correct
3 Correct 12 ms 4248 KB Output is correct
4 Correct 13 ms 4248 KB Output is correct
5 Correct 13 ms 4372 KB Output is correct
6 Correct 13 ms 4456 KB Output is correct
7 Correct 13 ms 4456 KB Output is correct
8 Correct 14 ms 4512 KB Output is correct
9 Correct 13 ms 4512 KB Output is correct
10 Correct 13 ms 4512 KB Output is correct
11 Correct 13 ms 4512 KB Output is correct
12 Correct 13 ms 4512 KB Output is correct
13 Correct 14 ms 4512 KB Output is correct
14 Correct 15 ms 4540 KB Output is correct
15 Correct 13 ms 4540 KB Output is correct
16 Correct 13 ms 4540 KB Output is correct
17 Correct 13 ms 4540 KB Output is correct
18 Correct 14 ms 4540 KB Output is correct
19 Correct 15 ms 4604 KB Output is correct
20 Correct 13 ms 4604 KB Output is correct
21 Correct 13 ms 4604 KB Output is correct
22 Correct 13 ms 4604 KB Output is correct
23 Correct 14 ms 4604 KB Output is correct
24 Correct 13 ms 4604 KB Output is correct
25 Correct 13 ms 4604 KB Output is correct
26 Correct 14 ms 4604 KB Output is correct
27 Correct 14 ms 4604 KB Output is correct
28 Correct 14 ms 4604 KB Output is correct
29 Correct 14 ms 4604 KB Output is correct
30 Correct 13 ms 4604 KB Output is correct
31 Correct 14 ms 4604 KB Output is correct
32 Correct 14 ms 4604 KB Output is correct
33 Correct 13 ms 4604 KB Output is correct
34 Correct 14 ms 4604 KB Output is correct
35 Correct 13 ms 4604 KB Output is correct
36 Correct 14 ms 4604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 4604 KB Output is correct
2 Correct 15 ms 4604 KB Output is correct
3 Correct 13 ms 4604 KB Output is correct
4 Correct 13 ms 4604 KB Output is correct
5 Correct 13 ms 4604 KB Output is correct
6 Correct 13 ms 4604 KB Output is correct
7 Correct 13 ms 4604 KB Output is correct
8 Correct 13 ms 4604 KB Output is correct
9 Correct 14 ms 4604 KB Output is correct
10 Correct 13 ms 4604 KB Output is correct
11 Correct 13 ms 4604 KB Output is correct
12 Correct 13 ms 4604 KB Output is correct
13 Correct 13 ms 4604 KB Output is correct
14 Correct 13 ms 4604 KB Output is correct
15 Correct 13 ms 4604 KB Output is correct
16 Correct 12 ms 4604 KB Output is correct
17 Correct 13 ms 4604 KB Output is correct
18 Correct 12 ms 4604 KB Output is correct
19 Correct 12 ms 4604 KB Output is correct
20 Correct 13 ms 4604 KB Output is correct
21 Correct 13 ms 4604 KB Output is correct
22 Correct 13 ms 4604 KB Output is correct
23 Correct 16 ms 4604 KB Output is correct
24 Correct 13 ms 4604 KB Output is correct
25 Correct 13 ms 4604 KB Output is correct
26 Correct 13 ms 4604 KB Output is correct
27 Correct 13 ms 4604 KB Output is correct
28 Correct 13 ms 4604 KB Output is correct
29 Correct 14 ms 4604 KB Output is correct
30 Correct 15 ms 4604 KB Output is correct
31 Correct 17 ms 4604 KB Output is correct
32 Correct 17 ms 4604 KB Output is correct
33 Correct 18 ms 4604 KB Output is correct
34 Correct 20 ms 4604 KB Output is correct
35 Correct 16 ms 4604 KB Output is correct
36 Correct 17 ms 4604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4604 KB Output is correct
2 Correct 14 ms 4604 KB Output is correct
3 Correct 13 ms 4604 KB Output is correct
4 Correct 13 ms 4604 KB Output is correct
5 Correct 14 ms 4604 KB Output is correct
6 Correct 16 ms 4604 KB Output is correct
7 Correct 13 ms 4604 KB Output is correct
8 Correct 14 ms 4604 KB Output is correct
9 Correct 13 ms 4604 KB Output is correct
10 Correct 15 ms 4604 KB Output is correct
11 Correct 14 ms 4604 KB Output is correct
12 Correct 13 ms 4604 KB Output is correct
13 Correct 13 ms 4604 KB Output is correct
14 Correct 13 ms 4604 KB Output is correct
15 Correct 15 ms 4604 KB Output is correct
16 Correct 15 ms 4604 KB Output is correct
17 Correct 15 ms 4604 KB Output is correct
18 Correct 19 ms 4604 KB Output is correct
19 Correct 23 ms 4604 KB Output is correct
20 Correct 22 ms 4604 KB Output is correct
21 Correct 23 ms 4604 KB Output is correct
22 Correct 22 ms 4604 KB Output is correct
23 Correct 16 ms 4604 KB Output is correct
24 Correct 23 ms 4604 KB Output is correct
25 Correct 30 ms 4604 KB Output is correct
26 Correct 40 ms 4608 KB Output is correct
27 Correct 42 ms 4608 KB Output is correct
28 Correct 41 ms 4608 KB Output is correct
29 Correct 42 ms 4608 KB Output is correct
30 Correct 49 ms 4608 KB Output is correct
31 Correct 47 ms 4608 KB Output is correct
32 Correct 60 ms 4608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 4608 KB Output is correct
2 Correct 16 ms 4608 KB Output is correct
3 Correct 14 ms 4608 KB Output is correct
4 Correct 16 ms 4608 KB Output is correct
5 Correct 16 ms 4608 KB Output is correct
6 Correct 14 ms 4608 KB Output is correct
7 Correct 15 ms 4608 KB Output is correct
8 Correct 13 ms 4608 KB Output is correct
9 Correct 14 ms 4608 KB Output is correct
10 Correct 13 ms 4608 KB Output is correct
11 Correct 13 ms 4608 KB Output is correct
12 Correct 16 ms 4608 KB Output is correct
13 Correct 38 ms 4608 KB Output is correct
14 Correct 14 ms 4608 KB Output is correct
15 Correct 14 ms 4608 KB Output is correct
16 Correct 14 ms 4608 KB Output is correct
17 Correct 13 ms 4608 KB Output is correct
18 Correct 14 ms 4608 KB Output is correct
19 Correct 13 ms 4608 KB Output is correct
20 Correct 15 ms 4608 KB Output is correct
21 Correct 13 ms 4608 KB Output is correct
22 Correct 13 ms 4608 KB Output is correct
23 Correct 15 ms 4608 KB Output is correct
24 Correct 15 ms 4608 KB Output is correct
25 Correct 14 ms 4608 KB Output is correct
26 Correct 16 ms 4608 KB Output is correct
27 Correct 13 ms 4608 KB Output is correct
28 Correct 15 ms 4648 KB Output is correct
29 Correct 14 ms 4648 KB Output is correct
30 Correct 14 ms 4648 KB Output is correct
31 Correct 14 ms 4648 KB Output is correct
32 Correct 15 ms 4648 KB Output is correct
33 Correct 14 ms 4648 KB Output is correct
34 Correct 13 ms 4648 KB Output is correct
35 Correct 15 ms 4648 KB Output is correct
36 Correct 14 ms 4648 KB Output is correct
37 Correct 16 ms 4648 KB Output is correct
38 Correct 14 ms 4648 KB Output is correct
39 Correct 15 ms 4648 KB Output is correct
40 Correct 20 ms 4648 KB Output is correct
41 Correct 21 ms 4648 KB Output is correct
42 Correct 17 ms 4648 KB Output is correct
43 Correct 19 ms 4648 KB Output is correct
44 Correct 17 ms 4648 KB Output is correct
45 Correct 19 ms 4648 KB Output is correct
46 Correct 19 ms 4648 KB Output is correct
47 Correct 18 ms 4648 KB Output is correct
48 Correct 20 ms 4648 KB Output is correct
49 Correct 26 ms 4648 KB Output is correct
50 Correct 35 ms 4648 KB Output is correct
51 Correct 41 ms 4648 KB Output is correct
52 Correct 40 ms 4648 KB Output is correct
53 Correct 41 ms 4648 KB Output is correct
54 Correct 41 ms 4648 KB Output is correct
55 Correct 45 ms 4648 KB Output is correct
56 Correct 16 ms 4648 KB Output is correct
57 Correct 32 ms 4648 KB Output is correct
58 Correct 32 ms 4648 KB Output is correct
59 Correct 37 ms 4648 KB Output is correct
60 Correct 41 ms 4648 KB Output is correct
61 Correct 38 ms 4648 KB Output is correct
62 Correct 41 ms 4648 KB Output is correct
63 Correct 51 ms 4648 KB Output is correct
64 Correct 33 ms 4648 KB Output is correct
65 Correct 16 ms 4648 KB Output is correct
66 Correct 27 ms 4648 KB Output is correct
67 Correct 25 ms 4648 KB Output is correct
68 Correct 33 ms 4648 KB Output is correct
69 Correct 44 ms 4648 KB Output is correct
70 Correct 38 ms 4648 KB Output is correct
71 Correct 38 ms 4648 KB Output is correct
72 Correct 42 ms 4648 KB Output is correct
73 Correct 38 ms 4648 KB Output is correct
74 Correct 50 ms 4648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 4648 KB Output is correct
2 Correct 13 ms 4648 KB Output is correct
3 Correct 12 ms 4648 KB Output is correct
4 Correct 12 ms 4648 KB Output is correct
5 Correct 14 ms 4648 KB Output is correct
6 Correct 14 ms 4648 KB Output is correct
7 Correct 15 ms 4648 KB Output is correct
8 Correct 16 ms 4648 KB Output is correct
9 Correct 16 ms 4648 KB Output is correct
10 Correct 14 ms 4648 KB Output is correct
11 Correct 15 ms 4648 KB Output is correct
12 Correct 15 ms 4648 KB Output is correct
13 Correct 17 ms 4648 KB Output is correct
14 Correct 14 ms 4648 KB Output is correct
15 Correct 15 ms 4724 KB Output is correct
16 Correct 13 ms 4724 KB Output is correct
17 Correct 13 ms 4724 KB Output is correct
18 Correct 14 ms 4724 KB Output is correct
19 Correct 13 ms 4724 KB Output is correct
20 Correct 16 ms 4724 KB Output is correct
21 Correct 16 ms 4724 KB Output is correct
22 Correct 14 ms 4724 KB Output is correct
23 Correct 15 ms 4724 KB Output is correct
24 Correct 15 ms 4724 KB Output is correct
25 Correct 14 ms 4724 KB Output is correct
26 Correct 15 ms 4724 KB Output is correct
27 Correct 18 ms 4724 KB Output is correct
28 Correct 21 ms 4724 KB Output is correct
29 Correct 21 ms 4724 KB Output is correct
30 Correct 18 ms 4724 KB Output is correct
31 Correct 18 ms 4724 KB Output is correct
32 Correct 16 ms 4724 KB Output is correct
33 Correct 16 ms 4724 KB Output is correct
34 Correct 16 ms 4724 KB Output is correct
35 Correct 20 ms 4724 KB Output is correct
36 Correct 27 ms 4724 KB Output is correct
37 Correct 33 ms 4724 KB Output is correct
38 Correct 40 ms 4724 KB Output is correct
39 Correct 42 ms 4724 KB Output is correct
40 Correct 47 ms 4724 KB Output is correct
41 Correct 41 ms 4724 KB Output is correct
42 Correct 43 ms 4724 KB Output is correct
43 Correct 16 ms 4724 KB Output is correct
44 Correct 28 ms 4724 KB Output is correct
45 Correct 33 ms 4724 KB Output is correct
46 Correct 49 ms 4724 KB Output is correct
47 Correct 36 ms 4724 KB Output is correct
48 Correct 48 ms 4724 KB Output is correct
49 Correct 45 ms 4724 KB Output is correct
50 Correct 39 ms 4724 KB Output is correct
51 Correct 48 ms 4724 KB Output is correct
52 Execution timed out 1091 ms 4724 KB Time limit exceeded
53 Halted 0 ms 0 KB -