# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
697661 | finn__ | Bitwise (BOI06_bitwise) | C++17 | 1097 ms | 300 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |