Submission #348036

#TimeUsernameProblemLanguageResultExecution timeMemory
348036Killer2501Bali Sculptures (APIO15_sculpture)C++14
100 / 100
583 ms21432 KiB
#include <bits/stdc++.h>
#define pb push_back
#define task "sequence"
#define pll pair<ll, ll>
#define pii pair<ll, pll>
#define fi first
#define se second
using ll = long long;
const long long mod = 1e12+7;
const ll N = 2005;
const int base = 350;
using ull = unsigned long long;
using namespace std;
ll n, m, t, k, T, a[N], cnt, lab[N], l, r, ans, u, tong, v, b[N];
long long dp[2][N], c[N];
string s, ss;
vector<ll> kq;
vector<ll> adj[N];
ll pw(ll k, ll n)
{
    ll total = 1;
    for(; n; n >>= 1)
    {
        if(n & 1)total = (total * k) % mod;
        k = (k * k) % mod;
    }
    return total;
}
bool check(int id)
{
    tong += (1ll<<id);
    fill_n(b, n+2, 0);
    fill_n(c, n+2, mod);
    for(int i = 1; i <= n; i ++)adj[i].clear();
    c[0] = 0;
    for(int i = 1; i <= n; i ++)
    {
        ll total = 0;
        for(int j = i; j <= n; j ++)
        {
            total += a[j];
            if((total & tong) == 0)adj[j].pb(i-1);
        }
    }
    for(int i = 1; i <= n; i ++)
    {
        for(ll x : adj[i])
        {
            b[i] = max(b[i], b[x]+1);
            c[i] = min(c[i], c[x]+1);
        }
    }
    tong -= (1ll<<id);
    return (b[n] >= l && c[n] <= r);
}
void sol()
{
    cin >> n >> l >> r;
    for(int i = 1; i <= n; i ++)cin >> a[i];
    for(int i = 60; i >= 0; i --)
    {
        if(check(i))tong += (1ll<<i);
        else ans += (1ll<<i);
    }
    cout << ans;
}
int main()
{
    if(fopen(task".in", "r")){
       freopen(task".in", "r", stdin);
       freopen(task".out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int ntest;
    ntest =  1;
    //cin >> ntest;
    while(ntest -- > 0)
    sol();

}
/*
6 1 3
8 1 2 1 5 4
*/

Compilation message (stderr)

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