Submission #68459

#TimeUsernameProblemLanguageResultExecution timeMemory
68459yusufakeBank (IZhO14_bank)C++98
100 / 100
222 ms14844 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e3+3; #define pb push_back vector < int > V[N]; bool H[20][1<<20]; int A[N],B[N],T[N*20],n,m,i,j,t,ans; void f(int i, int m){ if(ans) return; if(i == n) { ans = 1; return; } if(H[i][m]) return; H[i][m] = 1; int j, x = A[i]; for(j=0;j<V[x].size();j++){ if((V[x][j] & m) == V[x][j]) f(i+1,(m^V[x][j])); } } int main(){ scanf("%d%d",&n,&m); for(i=0;i<n;i++) { scanf("%d",&A[i]); T[ A[i] ] = 1; } for(i=0;i<m;i++) scanf("%d",&B[i]); for(i=1;i<(1<<m);i++){ t = 0; for(j=0;j<m;j++) if(i & (1 << j)) t += B[j]; if(!T[t]) continue; V[t].pb(i); } ans = 0; f(0,(1<<m)-1); puts(ans ? "YES" : "NO"); return 0; }

Compilation message (stderr)

bank.cpp: In function 'void f(int, int)':
bank.cpp:17:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(j=0;j<V[x].size();j++){
             ~^~~~~~~~~~~~
bank.cpp: In function 'int main()':
bank.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
bank.cpp:25:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=0;i<n;i++) { scanf("%d",&A[i]); T[ A[i] ] = 1; }
                        ~~~~~^~~~~~~~~~~~
bank.cpp:26:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=0;i<m;i++) scanf("%d",&B[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...