# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
558660 | Olympia | Bitwise (BOI06_bitwise) | C++17 | 1 ms | 304 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>
#include <cmath>
using namespace std;
bool canDo (vector<pair<int,int>> &v, int x) {
//can we achieve some supermask of x
bool change = false;
for (auto& p: v) {
if ((int)log2(p.first) == (int)log2(p.second)) {
int bt = (1 << (int)log2(p.first));
if (x & bt) x -= bt;
p.first -= bt, p.second -= bt;
change = true;
}
}
for (auto& p: v) {
if ((1 << (int)log2(p.second)) > x) {
return true;
}
}
int cntr = 0;
for (auto& p: v) {
cntr += ((1 << (int)log2(p.second)) == (1 << (int)log2(x)));
}
if (cntr >= 2) {
return true;
}
for (auto& p: v) {
if ((int)log2(p.second) == (int)log2(x)) {
int bt = log2(x);
p.second -= (1 << bt);
}
}
return false;
}
int main() {
int n, m;
cin >> n >> m;
int tot[m];
for (int i = 0; i < m; i++) {
cin >> tot[i];
}
vector<vector<pair<int,int>>> vec;
int ind = 0;
for (int i = 0; i < m; i++) {
vec.emplace_back();
while (tot[i]--) {
pair<int,int> p;
cin >> p.first >> p.second;
vec.back().push_back(p);
}
}
cout << canDo(vec.back(), 4);
return 0;
for (int i = 0; i < vec.size(); i++) {
for (auto& p: vec[i]) {
cout << p.first << " " << p.second << " | ";
}
cout << '\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |