# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
317510 | sofapuden | Bitwise (BOI06_bitwise) | C++14 | 1 ms | 384 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;
int n, p;
vector<int> sz;
vector<array<int,2>> hl;
bool check(int pos){
int cur = 0;
for(int i = 0; i < p; ++i){
bool good = false;
for(int j = cur; j < cur+sz[i]; ++j)if(hl[j][1]&(1<<pos))good = true;
if(!good){
for(int j = 0; j < n; ++j){
if((hl[j][1] & (1<<pos)) && !(hl[j][0] & (1<<pos))){
for(int z = 0; z < pos; ++z)hl[j][1]|=(1<<z);
}
}
return false;
}
cur+=sz[i];
}
cur = 0;
for(int i = 0; i < p; ++i){
bool good = false;
for(int j = cur; j < cur+sz[i]; ++j)if((hl[j][1] & (1<<pos)) && (hl[j][0] & (1<<pos)))good = true;
for(int j = cur; j < cur+sz[i]; ++j){
if((hl[j][1] & (1<<pos)) && !(hl[j][0] & (1<<pos))){
if(!good){
good = true;
hl[j][0] = 0;
}
else for(int z = 0; z < pos; ++z)hl[j][1]|=(1<<z);
}
}
cur+=sz[i];
}
return true;
}
int main(){
cin >> n >> p;
sz.resize(p);
hl.resize(n);
for(auto &x : sz)cin >> x;
for(auto &x : hl)cin >> x[0] >> x[1];
int ans = 0;
for(int i = 31; ~i; --i)if(check(i))ans+=(1<<i);
cout << ans << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |