Submission #735298

# Submission time Handle Problem Language Result Execution time Memory
735298 2023-05-03T22:07:36 Z DrearyJoke Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 324 KB
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define END "\n"
#define rall(v) (v).rbegin(), (v).rend()
#define all(v) (v).begin(), (v).end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int D = 5;
ll solve_small(int n, int a, int b) {
    vector<ll> A(n + 1);
    for (int i = 1; i <= n; ++i) cin >> A[i];
    ll ans = (1LL << D) - 1;
    for (int bit = D - 1; bit >= 0; --bit) {
        vector<vector<bool>> dp(b + 1, vector<bool>(n + 1, false));
        dp[0][0] = 1;
        ans -= (1LL << bit);
        bool ok = false;
        for (int j = 1; j <= b; ++j) {
            for (int i = 1; i <= n; ++i) { 
                ll sum = A[i];
                for (int k = i - 1; k >= 0; --k) {
                    if ((sum | ans) == ans) {
                        dp[j][i] = dp[j][i] || dp[j - 1][k];
                    }
                    sum += A[k];
                }
            }
        }
        for (int i = a; i <= b; ++i) if (dp[i][n]) ok = 1;
        // cout << bit << " " << ok << endl;
        if (!ok) ans += (1LL << bit); 
    }
    return ans;
}


ll solve_large(int n, int a, int b) {
    return 0;
}
void solve(){
    int n, a, b;
    cin >> n >> a >> b;
    if (n <= 100) cout << solve_small(n, a, b);
    else cout << solve_large(n, a, b);    
    cout << END;
}
int main()
{
    fastio
    int t = 1;
    // cin>> t;
    while(t--) solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Incorrect 1 ms 316 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 316 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 320 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -