Submission #397847

#TimeUsernameProblemLanguageResultExecution timeMemory
397847juggernautBali Sculptures (APIO15_sculpture)C++14
71 / 100
1085 ms748 KiB
#include<bits/stdc++.h> #define fr first #define sc second using namespace std; void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} typedef long long ll; #define USING_ORDERED_SET 0 #if USING_ORDERED_SET #include<bits/extc++.h> using namespace __gnu_pbds; template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #endif template<class T>void umax(T &a,T b){if(a<b)a=b;} template<class T>void umin(T &a,T b){if(b<a)a=b;} #ifdef IOI2021SG #define printl(args...)printf(args) #else #define printl(args...)((void)0) #endif int n,l,r,a[2005]; int main(){ scanf("%d%d%d",&n,&l,&r); for(int i=0;i<n;i++)scanf("%d",&a[i]); ll ans=0; for(int bit=45;bit>=0;bit--){ vector<bitset<2005>>dp(n+5); dp[0]=1; for(int j=1;j<=n;j++){ ll sum=0; for(int k=j-1;k>=0;k--){ sum+=a[k]; if(((sum>>(bit+1))|ans)==ans&&!((sum>>bit)&1))dp[j]|=dp[k]<<1; } } bool flag=false; for(int i=l;i<=r;i++)flag|=dp[n][i]; ans<<=1; ans|=(!flag); } printf("%lld",ans); }

Compilation message (stderr)

sculpture.cpp: In function 'void usaco(std::string)':
sculpture.cpp:5:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:5:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp: In function 'int main()':
sculpture.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |     scanf("%d%d%d",&n,&l,&r);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
sculpture.cpp:23:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |     for(int i=0;i<n;i++)scanf("%d",&a[i]);
      |                         ~~~~~^~~~~~~~~~~~
#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...