Submission #563573

# Submission time Handle Problem Language Result Execution time Memory
563573 2022-05-17T14:58:31 Z myrcella Bali Sculptures (APIO15_sculpture) C++17
21 / 100
1000 ms 1748 KB
//by szh
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}

const int maxn = 2e3+10;

int n,A,B;
ll val[maxn];
bool dp1[maxn][maxn];
int dp2[maxn];

bool check(ll mask,ll cur) {
	if (A==1) {
		dp1[0][0]=1;
		rep(i,1,n+1) {
			rep(j,0,min(B+1,i+1)) {
				dp1[i][j] = 0;
				rep(k,0,i) {
					if (dp1[k][j-1]==1 and ((((val[i]-val[k])>>cur)|mask) == mask)) {
						dp1[i][j]=1;
						break;
					}
				}
				if (dp1[i][j]==1 and i==n and j>=A) return true;
			}
		}
		return false;
	}
	else {
		dp2[0] = 0;
		rep(i,1,n+1) {
			dp2[i] = B+1;
			rep(j,0,i) {
				if ((((val[i]-val[j])>>cur)|mask) == mask) dp2[i] = min(dp2[i],dp2[j]+1);
			}
			if (dp2[i]>B) return false;
		}
		return true;
	}
}

int main() {
//	freopen("input.txt","r",stdin);	
	std::ios::sync_with_stdio(false);cin.tie();
	cin>>n>>A>>B;
	val[0]=0;
	rep(i,1,n+1) cin>>val[i],val[i]+=val[i-1];
	ll mask = 0, cur = 40;
	while (cur>=0) {
		mask*=2;
		if (!check(mask,cur)) mask+=1;
		cur--;
	}
	cout<<mask;
	return 0;
}
/*
6 2 3
8 1 2 1 5 4
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Incorrect 1 ms 212 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Incorrect 0 ms 212 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 480 KB Output is correct
27 Correct 6 ms 468 KB Output is correct
28 Correct 10 ms 532 KB Output is correct
29 Correct 10 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 6 ms 468 KB Output is correct
32 Correct 9 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Incorrect 0 ms 212 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 424 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 6 ms 468 KB Output is correct
38 Correct 10 ms 468 KB Output is correct
39 Correct 12 ms 532 KB Output is correct
40 Correct 1 ms 468 KB Output is correct
41 Correct 6 ms 528 KB Output is correct
42 Correct 9 ms 532 KB Output is correct
43 Correct 2 ms 436 KB Output is correct
44 Correct 5 ms 468 KB Output is correct
45 Correct 10 ms 516 KB Output is correct
46 Correct 12 ms 532 KB Output is correct
47 Correct 13 ms 468 KB Output is correct
48 Correct 1 ms 468 KB Output is correct
49 Correct 13 ms 532 KB Output is correct
50 Correct 14 ms 532 KB Output is correct
51 Correct 5 ms 468 KB Output is correct
52 Correct 640 ms 1448 KB Output is correct
53 Execution timed out 1067 ms 1748 KB Time limit exceeded
54 Halted 0 ms 0 KB -