Submission #495928

#TimeUsernameProblemLanguageResultExecution timeMemory
495928ntabc05101Bali Sculptures (APIO15_sculpture)C++14
37 / 100
12 ms368 KiB
#include<bits/stdc++.h> using namespace std; #define taskname "" const int lgN = 41; int main() { if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } else { if (fopen(taskname".in", "r")) { freopen(taskname".in", "r", stdin); freopen(taskname".out", "w", stdout); } } cin.tie(0)->sync_with_stdio(0); int n, a, b; cin >> n >> a >> b; long long y[n + 1]; y[0] = 0; for (int i = 1; i <= n; i++) { cin >> y[i]; y[i] += y[i - 1]; } long long res = 0; if (n > 100) { pair<bool, int> dp[n + 1]; for (int x = lgN - 1; ~x; x--) { dp[0] = {1, 0}; for (int i = 1; i <= n; i++) { dp[i] = {0, 0}; for (int j = i - 1; ~j; j--) { if ((res >> x) == (((y[i] - y[j]) | res) >> x)) { dp[i] = max(dp[i], dp[j]); } } dp[i].second--; } if (!dp[n].first || -dp[n].second > b) { res |= 1 << x; } } cout << res << "\n"; } else { bool dp[n + 1][n + 1]; for (int x = lgN - 1; ~x; x--) { memset(dp, 0, sizeof(dp)); dp[0][0] = 1; for (int i = 1; i <= n; i++) { for (int k = i - 1; ~k; k--) { if ((res >> x) == (((y[i] - y[k]) | res) >> x)) { for (int j = 1; j <= i; j++) { dp[i][j] |= dp[k][j - 1]; } } } } int chk = 1; for (int j = a; j <= b; j++) { if (dp[n][j]) { chk = 0; break; } } res |= chk << x; } cout << res << "\n"; } return 0; }

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:10:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   freopen(taskname".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:11:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   freopen(taskname".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:15:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |    freopen(taskname".in", "r", stdin);
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:16:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |    freopen(taskname".out", "w", stdout);
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...