Submission #1013027

#TimeUsernameProblemLanguageResultExecution timeMemory
1013027vjudge1Bank (IZhO14_bank)C++17
100 / 100
424 ms46872 KiB
#include<bits/stdc++.h> using namespace std; int n, m, a[1001], b[1001]; vector<int> v[20001]; unordered_map<int, bool> used[25]; void rec(int i, int mask){ if(used[i][mask]) return; used[i][mask] = true; if(i == n){ cout << "YES"; exit(0); } for(auto to : v[a[i]]){ if((to & mask) == 0){ rec(i+1, mask ^ to); } } } main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 0; i < n; i++){ cin >> a[i]; } for(int j = 0; j < m; j++){ cin >> b[j]; } for(int mask = 0; mask < (1<<m); mask++){ int sum = 0; for(int j = 0; j < m; j++){ if(mask & (1 << j)){ sum += b[j]; } } v[sum].push_back(mask); } rec(0, 0); cout << "NO"; }

Compilation message (stderr)

bank.cpp:19:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 |  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...