제출 #725900

#제출 시각아이디문제언어결과실행 시간메모리
725900AndrijaM은행 (IZhO14_bank)C++14
19 / 100
1088 ms4424 KiB
#include <bits/stdc++.h> using namespace std; int kolku; int n,m; int x[20]; int y[20]; int dp[(1<<20)]; bool f(int idx,int mask) { if(idx==n) { return 1; } if(mask==kolku) { return 0; } if(dp[mask]!=-1)return dp[mask]; int rez=0; for(int i=0;i<(1<<m);i++) { int sum=0; if(i&mask) { for(int bit=0;bit<m;bit++) { if(i&mask) { if(i&(1<<bit) && mask&(1<<bit)) { i^=(1<<bit); int b=bit+1; if(b<m) { i|=(1<<bit); } } else { if(i&(1<<bit)) i^=(1<<bit); } } else { break; } } i--; } else { for(int bit=0;bit<m;bit++) { if(i&(1<<bit)) { sum+=y[bit]; } } if(sum==x[idx]) { int bmask=mask; bmask|=i; rez|=f(idx+1,bmask); } } } return dp[mask]=rez; } int main() { ios::sync_with_stdio(0); memset(dp,-1,sizeof dp); cin>>n>>m; kolku=(1<<m)-1; for(int i=0;i<n;i++)cin>>x[i]; for(int i=0;i<m;i++)cin>>y[i]; if(f(0,0)) { cout<<"YES"<<endl; return 0; } cout<<"NO"<<endl; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'bool f(int, int)':
bank.cpp:71:20: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   71 |     return dp[mask]=rez;
      |            ~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...