Submission #23046

#TimeUsernameProblemLanguageResultExecution timeMemory
23046BruteforcemanBali Sculptures (APIO15_sculpture)C++11
100 / 100
99 ms2092 KiB
#include "bits/stdc++.h" using namespace std; int a[2005]; int dp[2005]; int n, A, B; typedef long long Long; Long p[2005]; const int bit = 42; long long mask; const int inf = 1e8; void solve (int x) { mask ^= 1LL << x; for(int i = 1; i <= n; i++) { dp[i] = inf; for(int j = 0; j < i; j++) { long long sum = p[i] - p[j]; if((sum | mask) == mask) dp[i] = min(dp[i], dp[j] + 1); } } if(dp[n] > B) { mask |= (1LL << x); } } int xp[105][105]; void fuck(int x) { mask ^= 1LL << x; memset(xp, 0, sizeof xp); xp[0][0] = 1; for(int i = 1; i <= n; i++) { for(int j = 1; j <= i; j++) { for(int k = 0; k < i; k++) { long long sum = p[i] - p[k]; if((sum | mask) == mask) { xp[i][j] |= xp[k][j - 1]; } } } } int cnt = 0; for(int i = A; i <= B; i++) { cnt |= xp[n][i]; } if(!cnt) { mask |= 1LL << x; } } int main(int argc, char const *argv[]) { scanf("%d %d %d", &n, &A, &B); for(int i = 1; i <= n; i++) { scanf("%d", a + i); } for(int i = 1; i <= n; i++) { p[i] = p[i - 1] + a[i]; } for(int i = 0; i <= bit; i++) { mask |= 1LL << i; } for(int x = bit; x >= 0; x--) { if(A == 1) solve(x); else fuck(x); } printf("%lld\n", mask); return 0; }

Compilation message (stderr)

sculpture.cpp: In function 'int main(int, const char**)':
sculpture.cpp:54:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &A, &B);
                               ^
sculpture.cpp:56:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a + i);
                     ^
#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...