Submission #1010220

#TimeUsernameProblemLanguageResultExecution timeMemory
1010220MilosMilutinovicBitwise (BOI06_bitwise)C++14
25 / 100
3 ms604 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, p; cin >> n >> p; vector<int> k(p); for (int i = 0; i < p; i++) { cin >> k[i]; } vector<int> from(n); vector<int> to(n); for (int i = 0; i < n; i++) { cin >> from[i] >> to[i]; } auto Check = [&](int target) { int ptr = 0; for (int g = 0; g < p; g++) { int L = ptr, R = ptr + k[g]; bool found = false; { int total = 0; for (int i = L; i < R; i++) { total |= (to[i]); } if ((total & target) == target) { found = true; } } for (int i = L; i < R; i++) { for (int b = 0; b < 30; b++) { if (to[i] >> b & 1) { int val = 0; for (int t = 0; t < 30; t++) { if (t == b) { continue; } if (t < b) { val += (1 << t); } else { if (to[i] >> t & 1) { val += (1 << t); } } } int total = val; for (int j = L; j < R; j++) { if (i == j) { continue; } total |= to[j]; } if ((total & target) == target) { found = true; } } } } if (!found) { return false; } ptr = R; } return true; }; int res = 0; for (int b = 30; b >= 0; b--) { if (Check(res + (1 << b))) { res += (1 << b); } } cout << res << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...