# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
93306 | 2019-01-07T13:57:45 Z | 3zp | Bank (IZhO14_bank) | C++14 | 131 ms | 20956 KB |
#include<bits/stdc++.h> using namespace std; int n, m; int f[2000009]; int A[2000009], B[2000009]; long long C[2000009]; void CO(vector<int> &a, vector<int> b){ for(int i = 0; i < (1 << m); i++) A[i] = 0, B[i] = 0; for(int i = 0; i < a.size(); i++) A[a[i]] = 1; for(int i = 0; i < b.size(); i++) B[b[i]] = 1; for(int i = 0; i < m; i++) for(int j = 0; j < (1 << m); j++) if(j & (1 << i)) A[j] += A[j ^ (1 << i)], B[j] += B[j ^ (1 << i)]; for(int i = 0; i < (1 << m); i++) C[i] = A[i] * B[i]; for(int i = 0; i < m; i++) for(int j = 0; j < (1 << m); j++) if(j & (1 << i)) C[j] -= C[j ^ (1 << i)]; a.clear(); for(int i = 0; i < (1 << m); i++) if(C[i]) a.push_back(i); } int a[29], b[29]; vector<int> v[29]; main(){ cin >> n >> m; int sa = 0; for(int i = 0; i < n; i++){ cin >> a[i]; sa += a[i]; } for(int i = 0; i < m; i++){ cin >> b[i]; } for(int i = 0; i < (1 << m); i++){ int S = 0, k = 0; for(int j = 0; j < m; j++){ if((1 << j) & i) S += b[j], k++; } if(k > m - n + 1) continue; for(int j = 0; j < n; j++){ if(a[j] == S) v[j].push_back(i); } if(S == sa) f[i] = 1; } vector<int> V; V.push_back(0); for(int i = 0; i < n; i++){ CO(V, v[i]); } for(int i = 0; i < V.size(); i++){ if(f[V[i]]){ cout <<"YES"<<endl; return 0; } } cout << "NO" << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 11 ms | 1060 KB | Output is correct |
5 | Correct | 129 ms | 16760 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 131 ms | 20956 KB | Output is correct |
9 | Correct | 125 ms | 16888 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 632 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 11 ms | 1060 KB | Output is correct |
5 | Correct | 129 ms | 16760 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 131 ms | 20956 KB | Output is correct |
9 | Correct | 125 ms | 16888 KB | Output is correct |
10 | Incorrect | 2 ms | 376 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |