Submission #1107513

#TimeUsernameProblemLanguageResultExecution timeMemory
1107513vjudge1Bank (IZhO14_bank)C++17
0 / 100
3 ms6992 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define nn "\n"; #define pb push_back #define all(v) (v).begin() , (v).end() const int N = 2e5+ 4; int a[N] , b[N]; vector<int>g[N]; int n , T , q , m ; void dfs(int v , int x ){ if(v == n ){ cout << "YES"; exit(0); } for(auto at:g[v+1]){ if(x&at== 0 ){ x|=at; dfs(x , v + 1 ); } } } signed main(){ ios_base::sync_with_stdio(0) , cin.tie(0); cin>> n >> m ; for(int i=1 ; i <= n ;i++)cin>> a[i]; for(int i=0 ; i < m; i++)cin>> b[i]; for(int i = 0 ; i < (1 << m ) - 1; i++){ int sum =0 ; for(int j =0 ; j < m; j++){ if(( i >> j )&1 ){ sum+=b[j]; } } g[sum].pb(i); } for(int i=0 ; i < g[1].size() ; i++){ dfs(1 , g[1][i]); } cout << "NO"; }

Compilation message (stderr)

bank.cpp: In function 'void dfs(long long int, long long int)':
bank.cpp:17:16: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   17 |         if(x&at== 0 ){
      |              ~~^~~~
bank.cpp: In function 'int main()':
bank.cpp:37:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i=0 ; i < g[1].size() ; 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...