Submission #1073106

#TimeUsernameProblemLanguageResultExecution timeMemory
1073106vjudge1은행 (IZhO14_bank)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define ff first #define ss second #define pb push_back const ll MOD=1000000007; int n,m,a[20],b[20]; unordered_map<ll,bool>was[21]; vector<int>v[1001]; bool f(int cur=0, int used=0){ if(was[cur][used]) return 0; if(cur==n) return 1; was[cur][used]=1; for(int y:v[a[cur]]) if(y&used==0) if(f(cur+1,used+y)) return 1; return 0; } void solve(){ cin>>n>>m; for(int i=0; i<n; i++) cin>>a[i]; for(int i=0; i<m; i++) cin>>b[i]; for(int i=1; i<(1<<m); i++){ int sum=0; for(int j=0; j<m; j++) if((1<<j)&i) sum+=b[j]; if(sum<=1000) v[sum].pb(i); } if(f()) cout<<"YES"; else cout<<"NO"; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t=1; // cin>>t; for(int _=0; _<t; _++){ // cout<<"Case "<<_+1<<":\n"; solve(); } return 0; } //080129552180

Compilation message (stderr)

bank.cpp: In function 'bool f(int, int)':
bank.cpp:18:32: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   18 |  for(int y:v[a[cur]]) if(y&used==0) if(f(cur+1,used+y)) return 1;
      |                            ~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...