Submission #697661

#TimeUsernameProblemLanguageResultExecution timeMemory
697661finn__Bitwise (BOI06_bitwise)C++17
30 / 100
1097 ms300 KiB
#include <bits/stdc++.h> using namespace std; vector<unsigned> k, a, b; void find_max(vector<unsigned> &v, size_t i, unsigned &max_value) { if (i == v.size()) { auto it = v.begin(); unsigned x = UINT_MAX; for (size_t j = 0; j < k.size(); j++) { unsigned y = 0; for (size_t h = 0; h < k[j]; h++) y |= *it++; x &= y; } max_value = max(max_value, x); return; } for (v[i] = a[i]; v[i] <= b[i]; v[i]++) find_max(v, i + 1, max_value); } int main() { size_t n, p; cin >> n >> p; k = vector<unsigned>(p); a = vector<unsigned>(n); b = vector<unsigned>(n); for (unsigned &x : k) cin >> x; for (size_t i = 0; i < n; i++) cin >> a[i] >> b[i]; unsigned max_value = 0; vector<unsigned> v(n); find_max(v, 0, max_value); cout << max_value << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...