Submission #671748

#TimeUsernameProblemLanguageResultExecution timeMemory
671748smartmonky은행 (IZhO14_bank)C++14
19 / 100
53 ms2692 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() using namespace std; const int N = 1e5; vector <int> g[N]; int n, vis[25][N]; void rec(int pos, int v){ if(pos == n + 1){ cout <<"YES"; exit(0); } vis[pos][v] = 1; for(auto to : g[pos]){ if((to & v) == v && !vis[pos + 1][(v ^ to)]) rec(pos + 1, (v ^ to)); } } main(){ int m; cin >> n >> m; vector <int> v(n + 1), a(m + 1); for(int i = 1; i <= n; i++){ cin >> v[i]; } for(int i = 1; i <= m; i++){ cin >> a[i]; } for(int i = 1; i <= (1 << m); i++){ int sum = 0; for(int j = 1; j <= m; j++) if(i & (1 << j)){ sum += a[j]; } for(int j = 1; j <= n; j++){ if(v[j] == sum)g[j].pb(i); } } rec(1, 0); cout << "NO"; }

Compilation message (stderr)

bank.cpp:24:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   24 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...