# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88436 | 2018-12-05T21:48:03 Z | xiaowuc1 | Bank (IZhO14_bank) | C++14 | 1000 ms | 14876 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, m; int bases[20]; vector<int> masks[1001]; void analyze(set<int>& lhs, set<int>& rhs) { for(int out: lhs) { int mask = -1+(1<<m)-out; for(int t = mask; t >= 0; t--) { t &= mask; if(rhs.count(t)) { cout << "YES\n"; exit(0); } } } } set<int> solve(vector<int> v, int leftover) { set<int> ret; ret.insert(0); for(int i = 0; i < v.size(); i++) { set<int> nret; for(int out2: ret) { for(int out: masks[v[i]]) { if(out&out2) continue; if(__builtin_popcount(out | out2) + (leftover + v.size()-i-1) > m) continue; nret.insert(out | out2); } } ret = nret; } return ret; } void solve() { cin >> n >> m; vector<int> a, b; for(int i = 0; i < n; i++) { int t; cin >> t; (i%2 ? a : b).push_back(t); } for(int i = 0; i < m; i++) cin >> bases[i]; for(int mask = 1; mask < (1<<m); mask++) { int v = 0; int t = mask; while(v <= 1000 && t) { v += bases[__builtin_ctz(t)]; t &= t-1; } if(v <= 1000) masks[v].push_back(mask); } set<int> reta = solve(a, b.size()); set<int> retb = solve(b, a.size()); if(reta.size() > retb.size()) { analyze(retb, reta); } else { analyze(reta, retb); } for(int outa: reta) { for(int outb: retb) { if((outa&outb) == 0) { cout << "YES\n"; return; } } } cout << "NO\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 444 KB | Output is correct |
3 | Correct | 2 ms | 444 KB | Output is correct |
4 | Correct | 3 ms | 620 KB | Output is correct |
5 | Correct | 26 ms | 6640 KB | Output is correct |
6 | Correct | 2 ms | 6640 KB | Output is correct |
7 | Correct | 2 ms | 6640 KB | Output is correct |
8 | Correct | 27 ms | 6640 KB | Output is correct |
9 | Correct | 25 ms | 6640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 6640 KB | Output is correct |
2 | Correct | 2 ms | 6640 KB | Output is correct |
3 | Correct | 2 ms | 6640 KB | Output is correct |
4 | Correct | 2 ms | 6640 KB | Output is correct |
5 | Correct | 2 ms | 6640 KB | Output is correct |
6 | Correct | 2 ms | 6640 KB | Output is correct |
7 | Correct | 2 ms | 6640 KB | Output is correct |
8 | Correct | 2 ms | 6640 KB | Output is correct |
9 | Correct | 2 ms | 6640 KB | Output is correct |
10 | Correct | 2 ms | 6640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 6640 KB | Output is correct |
2 | Correct | 2 ms | 6640 KB | Output is correct |
3 | Correct | 2 ms | 6640 KB | Output is correct |
4 | Correct | 2 ms | 6640 KB | Output is correct |
5 | Correct | 2 ms | 6640 KB | Output is correct |
6 | Correct | 2 ms | 6640 KB | Output is correct |
7 | Correct | 2 ms | 6640 KB | Output is correct |
8 | Correct | 2 ms | 6640 KB | Output is correct |
9 | Correct | 2 ms | 6640 KB | Output is correct |
10 | Correct | 2 ms | 6640 KB | Output is correct |
11 | Correct | 2 ms | 6640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 444 KB | Output is correct |
3 | Correct | 2 ms | 444 KB | Output is correct |
4 | Correct | 3 ms | 620 KB | Output is correct |
5 | Correct | 26 ms | 6640 KB | Output is correct |
6 | Correct | 2 ms | 6640 KB | Output is correct |
7 | Correct | 2 ms | 6640 KB | Output is correct |
8 | Correct | 27 ms | 6640 KB | Output is correct |
9 | Correct | 25 ms | 6640 KB | Output is correct |
10 | Correct | 2 ms | 6640 KB | Output is correct |
11 | Correct | 2 ms | 6640 KB | Output is correct |
12 | Correct | 2 ms | 6640 KB | Output is correct |
13 | Correct | 2 ms | 6640 KB | Output is correct |
14 | Correct | 2 ms | 6640 KB | Output is correct |
15 | Correct | 2 ms | 6640 KB | Output is correct |
16 | Correct | 2 ms | 6640 KB | Output is correct |
17 | Correct | 2 ms | 6640 KB | Output is correct |
18 | Correct | 2 ms | 6640 KB | Output is correct |
19 | Correct | 2 ms | 6640 KB | Output is correct |
20 | Correct | 2 ms | 6640 KB | Output is correct |
21 | Correct | 2 ms | 6640 KB | Output is correct |
22 | Correct | 2 ms | 6640 KB | Output is correct |
23 | Correct | 2 ms | 6640 KB | Output is correct |
24 | Correct | 2 ms | 6640 KB | Output is correct |
25 | Correct | 2 ms | 6640 KB | Output is correct |
26 | Correct | 2 ms | 6640 KB | Output is correct |
27 | Correct | 2 ms | 6640 KB | Output is correct |
28 | Correct | 2 ms | 6640 KB | Output is correct |
29 | Correct | 2 ms | 6640 KB | Output is correct |
30 | Correct | 2 ms | 6640 KB | Output is correct |
31 | Correct | 26 ms | 6640 KB | Output is correct |
32 | Correct | 84 ms | 7024 KB | Output is correct |
33 | Correct | 17 ms | 7024 KB | Output is correct |
34 | Correct | 7 ms | 7024 KB | Output is correct |
35 | Correct | 7 ms | 7024 KB | Output is correct |
36 | Correct | 7 ms | 7024 KB | Output is correct |
37 | Correct | 11 ms | 7024 KB | Output is correct |
38 | Correct | 13 ms | 7024 KB | Output is correct |
39 | Correct | 29 ms | 7024 KB | Output is correct |
40 | Correct | 21 ms | 7024 KB | Output is correct |
41 | Correct | 18 ms | 7024 KB | Output is correct |
42 | Correct | 108 ms | 7024 KB | Output is correct |
43 | Correct | 21 ms | 7024 KB | Output is correct |
44 | Correct | 6 ms | 7024 KB | Output is correct |
45 | Correct | 27 ms | 7024 KB | Output is correct |
46 | Correct | 25 ms | 7024 KB | Output is correct |
47 | Correct | 7 ms | 7024 KB | Output is correct |
48 | Correct | 25 ms | 7024 KB | Output is correct |
49 | Correct | 25 ms | 7024 KB | Output is correct |
50 | Correct | 341 ms | 14020 KB | Output is correct |
51 | Correct | 42 ms | 14020 KB | Output is correct |
52 | Correct | 402 ms | 14020 KB | Output is correct |
53 | Execution timed out | 1076 ms | 14876 KB | Time limit exceeded |
54 | Halted | 0 ms | 0 KB | - |