Submission #636206

#TimeUsernameProblemLanguageResultExecution timeMemory
636206ghostwriterBali Sculptures (APIO15_sculpture)C++14
100 / 100
87 ms448 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include <debug.h> #endif #define st first #define nd second #define pb push_back #define pf push_front #define _pb pop_back #define _pf pop_front #define lb lower_bound #define ub upper_bound #define mtp make_tuple #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll; typedef string str; template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i)) #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i)) #define EACH(i, x) for (auto &(i) : (x)) #define WHILE while #define file "TEST" mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); } /* Tran The Bao CTL - Da Lat Cay ngay cay dem nhung deo duoc cong nhan */ const int NMAX = 2001; int n, a, b, y[NMAX]; namespace subtask1234 { const int N = 101; int d[N][N]; void solve() { ll ans = (1LL << 37) - 1; FOS(x, 36, 0) { ans ^= 1LL << x; FOR(i, 1, n) d[0][i] = 0; d[0][0] = 1; FOR(i, 1, n) FOR(j, 0, n) { d[i][j] = 0; ll sum = 0; FOS(z, i, 1) { sum += y[z]; if ((sum | ans) == ans && j) d[i][j] = d[i][j] || d[z - 1][j - 1]; } } bool ok = 0; FOR(i, a, b) ok = ok || d[n][i]; if (!ok) ans ^= 1LL << x; } cout << ans; } } namespace subtask5 { const int N = 2001; int d[N]; void solve() { ll ans = (1LL << 41) - 1; FOS(x, 40, 0) { ans ^= 1LL << x; d[0] = 0; FOR(i, 1, n) { d[i] = n + 1; ll sum = 0; FOS(j, i, 1) { sum += y[j]; if ((sum | ans) == ans) d[i] = min(d[i], d[j - 1] + 1); } } if (d[n] > b) ans ^= 1LL << x; } cout << ans; } } signed main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); // freopen(file".inp", "r", stdin); // freopen(file".out", "w", stdout); cin >> n >> a >> b; FOR(i, 1, n) cin >> y[i]; if (n <= 100) { subtask1234::solve(); return 0; } subtask5::solve(); return 0; } /* 6 1 3 8 1 2 1 5 4 */

Compilation message (stderr)

sculpture.cpp: In function 'void subtask1234::solve()':
sculpture.cpp:25:31: warning: unnecessary parentheses in declaration of 'x' [-Wparentheses]
   25 | #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
      |                               ^
sculpture.cpp:43:3: note: in expansion of macro 'FOS'
   43 |   FOS(x, 36, 0) {
      |   ^~~
sculpture.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
sculpture.cpp:45:4: note: in expansion of macro 'FOR'
   45 |    FOR(i, 1, n) d[0][i] = 0;
      |    ^~~
sculpture.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
sculpture.cpp:47:4: note: in expansion of macro 'FOR'
   47 |    FOR(i, 1, n)
      |    ^~~
sculpture.cpp:24:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
sculpture.cpp:48:4: note: in expansion of macro 'FOR'
   48 |    FOR(j, 0, n) {
      |    ^~~
sculpture.cpp:25:31: warning: unnecessary parentheses in declaration of 'z' [-Wparentheses]
   25 | #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
      |                               ^
sculpture.cpp:51:5: note: in expansion of macro 'FOS'
   51 |     FOS(z, i, 1) {
      |     ^~~
sculpture.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
sculpture.cpp:57:4: note: in expansion of macro 'FOR'
   57 |    FOR(i, a, b) ok = ok || d[n][i];
      |    ^~~
sculpture.cpp: In function 'void subtask5::solve()':
sculpture.cpp:25:31: warning: unnecessary parentheses in declaration of 'x' [-Wparentheses]
   25 | #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
      |                               ^
sculpture.cpp:68:3: note: in expansion of macro 'FOS'
   68 |   FOS(x, 40, 0) {
      |   ^~~
sculpture.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
sculpture.cpp:71:4: note: in expansion of macro 'FOR'
   71 |    FOR(i, 1, n) {
      |    ^~~
sculpture.cpp:25:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   25 | #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
      |                               ^
sculpture.cpp:74:5: note: in expansion of macro 'FOS'
   74 |     FOS(j, i, 1) {
      |     ^~~
sculpture.cpp: In function 'int main()':
sculpture.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
sculpture.cpp:89:2: note: in expansion of macro 'FOR'
   89 |  FOR(i, 1, n) cin >> y[i];
      |  ^~~
#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...