제출 #495744

#제출 시각아이디문제언어결과실행 시간메모리
495744ntabc05101Bali Sculptures (APIO15_sculpture)C++14
0 / 100
1 ms316 KiB
#include<bits/stdc++.h> using namespace std; #define taskname "" const int lgN = 40; 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; int y[n + 1]; y[0] = 0; for (int i = 1; i <= n; i++) { cin >> y[i]; y[i] += y[i - 1]; } int res = 0; if (a == 1) { 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 (!(((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 (!(((y[i] - y[k]) ^ res) >> x)) { for (int j = 1; j <= i; j++) { dp[i][j] |= dp[k][j - 1]; } } } } int chk = 0; for (int j = a; j <= b; j++) { if (dp[n][j]) { chk = 1; break; } } res |= chk << x; } cout << res << "\n"; } return 0; }

컴파일 시 표준 에러 (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...