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