Submission #946533

#TimeUsernameProblemLanguageResultExecution timeMemory
946533amirhoseinfar1385Bali Sculptures (APIO15_sculpture)C++17
0 / 100
2 ms524 KiB
#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 (stderr)

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