Submission #1096891

#TimeUsernameProblemLanguageResultExecution timeMemory
1096891hihihihawBali Sculptures (APIO15_sculpture)C++17
100 / 100
100 ms600 KiB
#pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define pii pair<int,int> #define sz(v) (int)v.size() #define fi first #define se second #define INF 1223372036854775807 #define MOD 1000000007 #define cint(x) int x;cin>>x; #define cinarr(a,n) int a[n];for (int i=0;i<n;i++) cin>>a[i]; #define coutarr(a) for (auto d:a)cout<<d<<" "; cout<<endl; #define coutarrD(a) for (auto d:a) cout<<d.fi<<","<<d.se<<" "; cout<<endl; #define BERKAY_TUP ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define endl '\n' #define ld long double #define mid (start+end)/2 #define vvi vector<vector<int>> int t=1; int interactive=0; int usaco=0; int testCase=0; int dp[2001]; bool dp2[101][101]; void solve(){ int n,a,b; cin>>n>>a>>b; cinarr(z,n); if (a==1){ int ix=0; int rx=0; for (int j=60;j>=0;j--){ rx|=(1ll<<j); for (int i=0;i<=n;i++){ dp[i]=INF; } dp[0]=0; for (int i=0;i<n;i++){ int x=0; for (int l=i+1;l<=n;l++){ x+=z[l-1]; if ((x&rx)==0){ dp[l]=min(dp[l],dp[i]+1); } } } int y=0; if (dp[n]<=b) y=1; if (!y){ rx^=(1ll<<j); ix^=(1ll<<j); } } cout<<ix<<endl; } else{ int ix=0; int rx=0; for (int j=50;j>=0;j--){ rx|=(1ll<<j); for (int i=0;i<=n;i++){ for (int k=0;k<=b;k++) dp2[i][k]=false; } dp2[0][0]=true; for (int i=0;i<n;i++){ for (int k=0;k<b;k++){ int x=0; for (int l=i+1;l<=n;l++){ x+=z[l-1]; if ((x&rx)==0){ dp2[l][k+1]|=dp2[i][k]; } } } } int y=0; for (int k=a;k<=b;k++) y|=dp2[n][k]; if (!y){ //cout<<j<<endl; rx^=(1ll<<j); ix^=(1ll<<j); } } cout<<ix<<endl; } } int32_t main(){ BERKAY_TUP; if (usaco){ freopen("runaway.in", "r", stdin); freopen("runaway.out", "w", stdout); } if (!interactive){ #ifdef Local freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); //freopen("wormsort.out", "w", stdout); #endif } if (t==1) solve(); else{ cin>>t; while (t--){testCase++;solve();} } return 0; }

Compilation message (stderr)

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