Submission #1292368

#TimeUsernameProblemLanguageResultExecution timeMemory
1292368kamBank (IZhO14_bank)C++20
0 / 100
1 ms572 KiB
#include<unordered_map> #include<unordered_set> #include<algorithm> #include<iostream> #include<cstdlib> #include<iomanip> #include<cstring> #include<cassert> #include<numeric> #include<vector> #include<string> #include<chrono> #include<random> #include<stack> #include<queue> #include<cmath> #include<set> #include<map> #include<ios> using namespace std; int n, m; vector<int>a, b; vector<vector<int>>gp; bool dfs(int id, int vis) { if (id == n) return true; for (int& x : gp[a[id]]) { if ((vis ^ x) == (vis | x)) { if (dfs(id + 1, vis | x)) return true; } } return false; } void solve() { cin >> n >> m; a = vector<int>(n); b = vector<int>(m); gp = vector<vector<int>>(1 << m); for (int i = 0; i < n; i++) cin >> a[i]; for (int j = 0; j < m; j++) cin >> b[j]; for (int i = 0; i < (1 << m); i++) { int sum = 0; for (int j = 0; j < m; j++) { if ((1 << j) & i) sum += b[j]; } gp[sum].push_back(i); } cout << (dfs(0, 0) ? "YES" : "NO"); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); freopen("bank.in", "r", stdin); freopen("bank.out", "w", stdout); //signed _; cin >> _; while (_--) solve(); }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:57:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |     freopen("bank.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:58:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |     freopen("bank.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...