제출 #1326131

#제출 시각아이디문제언어결과실행 시간메모리
1326131hoangtien69Bali Sculptures (APIO15_sculpture)C++20
100 / 100
51 ms484 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 2e3 + 5; #define int long long #define LLONG_MIN -1e18 #define LLONG_MAX 1e18 int n, l, r; int maxx[MAXN]; int minn[MAXN]; int pre[MAXN]; int a[MAXN]; int ans = 0; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> l >> r; for (int i = 1; i <= n; i++) { cin >> a[i]; pre[i] = pre[i - 1] + a[i]; } for (int i = 40; i >= 0; i--) { int lim = ans | ((1LL << i) - 1); maxx[0] = 0; minn[0] = 0; for (int j = 1; j <= n; j++) { maxx[j] = LLONG_MIN; minn[j] = LLONG_MAX; for (int k = 1; k <= j; k++) { int val = pre[j] - pre[k - 1]; if ((val & lim) == val) { if (maxx[k - 1] != LLONG_MIN) maxx[j] = max(maxx[j], maxx[k - 1] + 1); if (minn[k - 1] != LLONG_MAX) minn[j] = min(minn[j], minn[k - 1] + 1); } } } if (maxx[n] < l || minn[n] > r) { ans |= (1LL << i); } } cout << ans; }

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

sculpture.cpp:5: warning: "LLONG_MIN" redefined
    5 | #define LLONG_MIN -1e18
      | 
In file included from /usr/lib/gcc/x86_64-linux-gnu/13/include/limits.h:205,
                 from /usr/lib/gcc/x86_64-linux-gnu/13/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-linux-gnu/13/include/limits.h:34,
                 from /usr/include/c++/13/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:38,
                 from sculpture.cpp:1:
/usr/include/limits.h:132: note: this is the location of the previous definition
  132 | #  define LLONG_MIN     (-LLONG_MAX-1)
      | 
sculpture.cpp:6: warning: "LLONG_MAX" redefined
    6 | #define LLONG_MAX 1e18
      | 
/usr/include/limits.h:135: note: this is the location of the previous definition
  135 | #  define LLONG_MAX     __LONG_LONG_MAX__
      |
#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...