# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
946533 | 2024-03-14T18:12:43 Z | amirhoseinfar1385 | Bali Sculptures (APIO15_sculpture) | C++17 | 2 ms | 524 KB |
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2") #include<bits/stdc++.h> using namespace std; const long long maxn=2000+10,lg=45; long long n,l,r,all[maxn],mainres; void vorod(){ cin>>n>>l>>r; for(long long i=1;i<=n;i++){ cin>>all[i]; } } long long check2(long long f){ vector<long long>dp(n+1); dp[0]=0; for(long long i=1;i<=n;i++){ dp[i]=n+2; long long sum=0; for(long long j=i;j>=1;j--){ sum+=all[j]; if(sum&f){ continue; } dp[i]=min(dp[i],dp[j-1]+1); } } return dp[n]<=r; } long long check1(long long f){ vector<vector<char>>dp(n+1,vector<char>(n+1)); dp[0][0]=1; for(long long i=1;i<=n;i++){ long long suma=0; for(long long j=i;j>=1;j--){ suma+=all[j]; for(long long h=1;h<=n;h++){ if(f&suma){ continue; } if(dp[j-1][h-1]==1){ dp[i][h]=1; } } } } for(long long i=l;i<=r;i++){ if(dp[n][i]==1){ return 1; } } return 0; } void solve1(){ long long fix=0; for(long long i=lg-1;i>=0;i--){ fix+=(1ll<<i); if(!check1(fix)){ fix-=(1ll<<i); } } mainres=(1ll<<lg)-1-fix; } void solve2(){ long long fix=0; for(long long i=lg-1;i>=0;i--){ fix+=(1ll<<i); if(!check2(fix)){ fix-=(1ll<<i); } } mainres=(1ll<<lg)-1-fix; } void khor(){ cout<<mainres<<"\n"; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); freopen("inp.txt","r",stdin); vorod(); if(l>1){ solve1(); }else{ solve2(); } khor(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 524 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |