Submission #563570

# Submission time Handle Problem Language Result Execution time Memory
563570 2022-05-17T14:48:39 Z myrcella Bali Sculptures (APIO15_sculpture) C++17
21 / 100
1000 ms 4288 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) {
		memset(dp1,0,sizeof(dp1));
		dp1[0][0]=1;
		rep(i,1,n+1) {
			rep(j,0,min(B+1,i+1)) {
				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;
			}
		}
		debug(233);
		return false;
	}
	else {
		memset(dp2,-1,sizeof(dp2));
		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 8 ms 4180 KB Output is correct
2 Correct 6 ms 4180 KB Output is correct
3 Correct 12 ms 4180 KB Output is correct
4 Correct 7 ms 4180 KB Output is correct
5 Correct 6 ms 4180 KB Output is correct
6 Correct 7 ms 4180 KB Output is correct
7 Correct 6 ms 4180 KB Output is correct
8 Correct 6 ms 4172 KB Output is correct
9 Correct 8 ms 4180 KB Output is correct
10 Correct 10 ms 4180 KB Output is correct
11 Correct 6 ms 4180 KB Output is correct
12 Correct 7 ms 4180 KB Output is correct
13 Correct 7 ms 4180 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 7 ms 4180 KB Output is correct
2 Correct 6 ms 4168 KB Output is correct
3 Correct 8 ms 4180 KB Output is correct
4 Correct 7 ms 4180 KB Output is correct
5 Correct 8 ms 4180 KB Output is correct
6 Correct 7 ms 4284 KB Output is correct
7 Correct 10 ms 4180 KB Output is correct
8 Correct 7 ms 4164 KB Output is correct
9 Correct 7 ms 4180 KB Output is correct
10 Correct 12 ms 4276 KB Output is correct
11 Correct 7 ms 4284 KB Output is correct
12 Correct 9 ms 4180 KB Output is correct
13 Correct 6 ms 4284 KB Output is correct
14 Incorrect 1 ms 340 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4180 KB Output is correct
2 Correct 9 ms 4280 KB Output is correct
3 Correct 11 ms 4180 KB Output is correct
4 Correct 12 ms 4284 KB Output is correct
5 Correct 8 ms 4180 KB Output is correct
6 Correct 9 ms 4284 KB Output is correct
7 Correct 6 ms 4180 KB Output is correct
8 Correct 8 ms 4180 KB Output is correct
9 Correct 12 ms 4284 KB Output is correct
10 Correct 7 ms 4180 KB Output is correct
11 Correct 8 ms 4284 KB Output is correct
12 Correct 7 ms 4180 KB Output is correct
13 Correct 11 ms 4280 KB Output is correct
14 Correct 7 ms 4180 KB Output is correct
15 Correct 9 ms 4244 KB Output is correct
16 Correct 9 ms 4280 KB Output is correct
17 Correct 6 ms 4180 KB Output is correct
18 Correct 8 ms 4272 KB Output is correct
19 Correct 8 ms 4164 KB Output is correct
20 Correct 6 ms 4180 KB Output is correct
21 Correct 8 ms 4180 KB Output is correct
22 Correct 7 ms 4284 KB Output is correct
23 Correct 11 ms 4164 KB Output is correct
24 Correct 7 ms 4280 KB Output is correct
25 Correct 11 ms 4180 KB Output is correct
26 Correct 10 ms 4180 KB Output is correct
27 Correct 14 ms 4280 KB Output is correct
28 Correct 21 ms 4284 KB Output is correct
29 Correct 19 ms 4180 KB Output is correct
30 Correct 7 ms 4180 KB Output is correct
31 Correct 15 ms 4172 KB Output is correct
32 Correct 18 ms 4180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4180 KB Output is correct
2 Correct 8 ms 4176 KB Output is correct
3 Correct 7 ms 4276 KB Output is correct
4 Correct 7 ms 4284 KB Output is correct
5 Correct 6 ms 4180 KB Output is correct
6 Correct 12 ms 4180 KB Output is correct
7 Correct 7 ms 4180 KB Output is correct
8 Correct 7 ms 4180 KB Output is correct
9 Correct 7 ms 4180 KB Output is correct
10 Correct 7 ms 4180 KB Output is correct
11 Correct 6 ms 4168 KB Output is correct
12 Correct 6 ms 4180 KB Output is correct
13 Correct 6 ms 4180 KB Output is correct
14 Incorrect 1 ms 340 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4180 KB Output is correct
2 Correct 7 ms 4280 KB Output is correct
3 Correct 6 ms 4280 KB Output is correct
4 Correct 7 ms 4180 KB Output is correct
5 Correct 7 ms 4276 KB Output is correct
6 Correct 7 ms 4168 KB Output is correct
7 Correct 7 ms 4164 KB Output is correct
8 Correct 11 ms 4180 KB Output is correct
9 Correct 7 ms 4280 KB Output is correct
10 Correct 6 ms 4180 KB Output is correct
11 Correct 6 ms 4180 KB Output is correct
12 Correct 7 ms 4180 KB Output is correct
13 Correct 7 ms 4280 KB Output is correct
14 Correct 11 ms 4280 KB Output is correct
15 Correct 9 ms 4180 KB Output is correct
16 Correct 7 ms 4180 KB Output is correct
17 Correct 7 ms 4180 KB Output is correct
18 Correct 7 ms 4180 KB Output is correct
19 Correct 7 ms 4180 KB Output is correct
20 Correct 9 ms 4180 KB Output is correct
21 Correct 10 ms 4180 KB Output is correct
22 Correct 7 ms 4180 KB Output is correct
23 Correct 7 ms 4220 KB Output is correct
24 Correct 8 ms 4272 KB Output is correct
25 Correct 6 ms 4168 KB Output is correct
26 Correct 10 ms 4168 KB Output is correct
27 Correct 7 ms 4180 KB Output is correct
28 Correct 8 ms 4284 KB Output is correct
29 Correct 8 ms 4180 KB Output is correct
30 Correct 8 ms 4288 KB Output is correct
31 Correct 8 ms 4284 KB Output is correct
32 Correct 7 ms 4180 KB Output is correct
33 Correct 7 ms 4180 KB Output is correct
34 Correct 7 ms 4180 KB Output is correct
35 Correct 8 ms 4180 KB Output is correct
36 Correct 16 ms 4180 KB Output is correct
37 Correct 17 ms 4180 KB Output is correct
38 Correct 21 ms 4180 KB Output is correct
39 Correct 34 ms 4164 KB Output is correct
40 Correct 7 ms 4180 KB Output is correct
41 Correct 13 ms 4168 KB Output is correct
42 Correct 19 ms 4176 KB Output is correct
43 Correct 10 ms 4180 KB Output is correct
44 Correct 17 ms 4180 KB Output is correct
45 Correct 19 ms 4280 KB Output is correct
46 Correct 25 ms 4180 KB Output is correct
47 Correct 27 ms 4260 KB Output is correct
48 Correct 7 ms 4168 KB Output is correct
49 Correct 24 ms 4168 KB Output is correct
50 Correct 31 ms 4284 KB Output is correct
51 Correct 15 ms 4172 KB Output is correct
52 Correct 871 ms 4284 KB Output is correct
53 Execution timed out 1076 ms 4180 KB Time limit exceeded
54 Halted 0 ms 0 KB -