제출 #531107

#제출 시각아이디문제언어결과실행 시간메모리
531107buidangnguyen05Bali Sculptures (APIO15_sculpture)C++14
100 / 100
102 ms452 KiB
/* input */ #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2010, M = 110; int n, L, R, f[N]; ll pref[N]; bool dp[M][M]; void sub1234() { ll cur = 0; for (int bit = 36; ~bit; --bit) { memset(dp, 0, sizeof(dp)); dp[0][0] = 1; cur |= (1LL << bit); for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) { for (int k = i; k; --k) { ll sum = pref[i] - pref[k - 1]; if (!(sum & cur)) dp[i][j] |= dp[k - 1][j - 1]; if (dp[i][j]) break; } } bool ok = 0; for (int i = L; i <= R; ++i) if (dp[n][i]) ok = 1; if (!ok) cur ^= (1LL << bit); } for (int bit = 36; ~bit; --bit) cur ^= (1LL << bit); cout << cur << "\n"; } void sub5() { ll cur = 0; for (int bit = 40; ~bit; --bit) { fill (f + 1, f + n + 1, n + 1); cur |= (1LL << bit); for (int i = 1; i <= n; ++i) for (int j = i; j; --j) { ll sum = pref[i] - pref[j - 1]; if (!(sum & cur)) f[i] = min(f[i], f[j - 1] + 1); } if (f[n] > R) cur ^= (1LL << bit); } for (int bit = 40; ~bit; --bit) cur ^= (1LL << bit); cout << cur << "\n"; } signed main() { cin.tie(0)->sync_with_stdio(0); if (fopen("task.inp", "r")) { freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); } cin >> n >> L >> R; for (int i = 1; i <= n; ++i) { int x; cin >> x; pref[i] = pref[i - 1] + x; } if (n <= 100) sub1234(); else sub5(); }

컴파일 시 표준 에러 (stderr) 메시지

sculpture.cpp: In function 'int main()':
sculpture.cpp:51:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |   freopen("task.inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:52:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |   freopen("task.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...