# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
697661 | finn__ | Bitwise (BOI06_bitwise) | C++17 | 1097 ms | 300 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |