제출 #1128005

#제출 시각아이디문제언어결과실행 시간메모리
1128005VinhLuuBali Sculptures (APIO15_sculpture)C++17
100 / 100
60 ms584 KiB
#include <bits/stdc++.h> #define ll long long #define all(lpv) lpv.begin(), lpv.end() #define pot(x, y) lower_bound(x.begin(), x.end(), y) - x.begin() + 1 using namespace std; #define lpv #ifndef lpv #include "AC.h" #endif // lpv //#define int long long const int N = 2e3 + 5; int n, a[N], L, R; ll s[N]; namespace sub4 { bool f[N][N]; void solve() { ll ret = 0, kq = 0; for(int bit = 36; bit >= 0; bit --) { for(int i = 0; i <= n; i ++) { for(int j = 0; j <= i; j ++) f[i][j] = 0; } f[0][0] = 1; for(int i = 1; i <= n; i ++) for(int j = 1; j <= i; j ++) { for(int pos = i - 1; pos >= j - 1; pos --) { if(!((s[i] - s[pos]) & (ret + (1ll << bit)))) f[i][j] = max(f[i][j], f[pos][j - 1]); } } bool ff = true; for(int i = L; i <= R; i ++) if(f[n][i]) { ff = false; break; } if(!ff) ret += (1ll << bit); else kq += (1ll << bit); } cout << kq; } } namespace sub5 { int f[N]; const int oo = 1e9; void solve() { ll ret = 0, kq = 0; for(int bit = 40; bit >= 0; bit --) { for(int i = 0; i <= n; i ++) f[i] = n + 1; f[0] = 0; for(int i = 1; i <= n; i ++) { for(int j = i - 1; j >= 0; j --) { if(!((s[i] - s[j]) & (ret + (1ll << bit)))) f[i] = min(f[i], f[j] + 1); } } if(f[n] <= R) ret += (1ll << bit); else kq += (1ll << bit); } cout << kq << "\n"; } } #ifdef lpv signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "v" 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 ++) { cin >> a[i]; s[i] = s[i - 1] + a[i]; } if(n <= 100) sub4 :: solve(); else sub5 :: solve(); } #endif // lpv

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

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