Submission #1192259

#TimeUsernameProblemLanguageResultExecution timeMemory
1192259ChuanChenBali Sculptures (APIO15_sculpture)C++20
0 / 100
1 ms328 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; int n, A, B; int sv[105]; bool dp[105][105]; //dp[i][g] := true <=> consigo usar [1..i], separar em g grupos, tal que bit b é 0 e prefixo é o que já tenho ll ans; bool isSubmask(int b, ll val){ return (ans>>b)-((ans>>b)|(val>>b)) == 0; } bool solve(int b){ for(int i = 1; i <= n; i++) for(int g = 1; g <= i; g++) dp[i][g] = false; for(int i = 1; i <= n; i++){ dp[i][1] = isSubmask(b, sv[i]); } for(int i = 1; i <= n; i++){ for(int g = 1; g <= i; g++) if(dp[i][g]){ for(int x = 1; i+x <= n; x++){ //sum(i+1, x) precisar ser bom dp[i+x][g+1] = isSubmask(b, sv[i+x]-sv[i]); } } } for(int g = A; g <= B; g++) if(dp[n][g]) return true; return false; } int main(){ cin >> n >> A >> B; for(int i = 1; i <= n; i++){ int a; cin >> a; sv[i] = sv[i-1]+a; } for(int b = 42; b >= 0; b--){ if(!solve(b)){ ans+=(1ll<<b); } } cout << ans << '\n'; }
#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...