Submission #563488

# Submission time Handle Problem Language Result Execution time Memory
563488 2022-05-17T10:26:12 Z penguin133 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int A[200005] ,P[200005];
int n,a,b;
int dp[105][105][105];
int calc(int i, int k, int prev){
	if(i == n && !k)return P[i] - P[prev];
	else if(i == n)return 1e18;
	else if(dp[i][k][prev])return dp[i][k][prev];
	else if(k)return dp[i][k][prev] = min((calc(i+1, k-1, i) | (P[i] - P[prev])), calc(i+1, k, prev));
	else return dp[i][k][prev] = calc(i+1, k, prev);
}
main(){
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> n >> a >> b;
	for(int i=1;i<=n;i++)cin >> A[i], P[i] = P[i-1] + A[i];
	int ans = 1e18;
	if(a == 1){
		int bit[35] = {0};
		for(int i=1;i<=n;i++){
			for(int j=0;j<=30;j++){
				if(A[i]>>j & 1)bit[j]++;
			}
		}
		ans = 0;
		for(int i=0;i<=30;i++)if(bit[i]%2)ans += (1<<i);
	}
	else{
		int tmp = 0;
		for(int i=1;i<=n;i++)tmp = max(tmp, A[i]);
	}
	cout << ans;
}

Compilation message

sculpture.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   14 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -