Submission #1094934

#TimeUsernameProblemLanguageResultExecution timeMemory
1094934rayan_bdBank (IZhO14_bank)C++17
100 / 100
650 ms203600 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-falign-jumps") #pragma GCC optimize("-falign-loops") #pragma GCC optimize("-falign-labels") #pragma GCC optimize("-fdevirtualize") #pragma GCC optimize("-fcaller-saves") #pragma GCC optimize("-fcrossjumping") #pragma GCC optimize("-fthread-jumps") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-fwhole-program") #pragma GCC optimize("-freorder-blocks") #pragma GCC optimize("-fschedule-insns") #pragma GCC optimize("inline-functions") #pragma GCC optimize("-ftree-tail-merge") #pragma GCC optimize("-fschedule-insns2") #pragma GCC optimize("-fstrict-aliasing") #pragma GCC optimize("-fstrict-overflow") #pragma GCC optimize("-falign-functions") #pragma GCC optimize("-fcse-skip-blocks") #pragma GCC optimize("-fcse-follow-jumps") #pragma GCC optimize("-fsched-interblock") #pragma GCC optimize("-fpartial-inlining") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-freorder-functions") #pragma GCC optimize("-findirect-inlining") #pragma GCC optimize("-fhoist-adjacent-loads") #pragma GCC optimize("-frerun-cse-after-loop") #pragma GCC optimize("inline-small-functions") #pragma GCC optimize("-finline-small-functions") #pragma GCC optimize("-ftree-switch-conversion") #pragma GCC optimize("-foptimize-sibling-calls") #pragma GCC optimize("-fexpensive-optimizations") #pragma GCC optimize("-funsafe-loop-optimizations") #pragma GCC optimize("inline-functions-called-once") #pragma GCC optimize("-fdelete-null-pointer-checks") #define pb push_back #define yes cout<<"YES\n" #define no cout<<"NO\n" #define ll long long const int mxN = 1048576; ll need[20],curr[20]; vector<ll> money[mxN]; ll dp[20][mxN]; bool f(ll i,ll mask){ if(i<0) return 1; if(money[need[i]].size()==0) return 0; if(dp[i][mask]!=-1) return dp[i][mask]; bool ok=0; for(auto it:money[need[i]]){ bool good=1; for(ll j=0;j<31;++j){ if((mask&(1ll<<j))&&(it&(1ll<<j))){ good=0; break; } } if(good){ ok|=f(i-1,mask|it); } } return dp[i][mask]=ok; } void solve(ll tc) { ll n,m;cin>>n>>m; memset(dp,-1,sizeof(dp)); for(ll i=0;i<n;++i) cin>>need[i]; for(ll i=0;i<m;++i) cin>>curr[i]; for(ll mask=0;mask<=(1ll<<m);++mask){ ll tot=0; for(ll i=0;i<m;++i){ if(mask&(1ll<<i)) tot+=curr[i]; } money[tot].pb(mask); } if(f(n-1,0)) yes; else no; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(0); return 0; }

Compilation message (stderr)

bank.cpp:24:39: warning: bad option '-fwhole-program' to pragma 'optimize' [-Wpragmas]
   24 | #pragma GCC optimize("-fwhole-program")
      |                                       ^
bank.cpp:31:41: warning: bad option '-fstrict-overflow' to pragma 'optimize' [-Wpragmas]
   31 | #pragma GCC optimize("-fstrict-overflow")
      |                                         ^
bank.cpp:33:41: warning: bad option '-fcse-skip-blocks' to pragma 'optimize' [-Wpragmas]
   33 | #pragma GCC optimize("-fcse-skip-blocks")
      |                                         ^
bank.cpp:47:51: warning: bad option '-funsafe-loop-optimizations' to pragma 'optimize' [-Wpragmas]
   47 | #pragma GCC optimize("-funsafe-loop-optimizations")
      |                                                   ^
bank.cpp:62:20: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
   62 | bool f(ll i,ll mask){
      |                    ^
bank.cpp:62:20: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
bank.cpp:62:20: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
bank.cpp:62:20: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
bank.cpp: In function 'bool f(long long int, long long int)':
bank.cpp:79:20: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   79 |  return dp[i][mask]=ok;
      |         ~~~~~~~~~~~^~~
bank.cpp: At global scope:
bank.cpp:82:17: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
   82 | void solve(ll tc) {
      |                 ^
bank.cpp:82:17: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
bank.cpp:82:17: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
bank.cpp:82:17: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
bank.cpp:101:13: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
  101 | signed main() {
      |             ^
bank.cpp:101:13: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
bank.cpp:101:13: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
bank.cpp:101:13: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...