Submission #563488

#TimeUsernameProblemLanguageResultExecution timeMemory
563488penguin133Bali Sculptures (APIO15_sculpture)C++14
0 / 100
1 ms340 KiB
#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 (stderr)

sculpture.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   14 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...