# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
949038 | Iskachun | Bitwise (BOI06_bitwise) | C++17 | 1073 ms | 432 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 <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int mx;
void f(vector<pair<int,int>>& a, int pos, int curr) {
if (pos == a.size()) {
mx = max(mx, curr);
//cout << curr << '\n';
return;
}
for (int x = a[pos].first; x <= a[pos].second; x++) {
//cout << x << ' ';
f(a, pos + 1, curr | x);
}
}
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, p; cin >> n >> p;
vector<int> k(p);
for (int &x : k) cin >> x;
int ans = (1ll << 31) - 1;
for (int l : k) {
vector<pair<int,int>> a(l);
for (auto &x : a) cin >> x.first >> x.second;
//for (auto x : a) cout << x.first << x.second << '\n';
mx = 0;
f(a, 0, 0);
//cout << mx << '\n';
ans &= mx;
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |