QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#500051 | #6730. Coolbits | MOUZ_donk | WA | 0ms | 3588kb | C++20 | 1.4kb | 2024-07-31 21:34:21 | 2024-07-31 21:34:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int T, n;
int l[N], r[N],c[N], choose[N];
void solve(){
cin>>n;
int min1=143322333;
for (int i = 1; i <= n; ++i){
cin>>l[i]>>r[i];
choose[i] = 0;
if(min1>r[i])
min1=r[i];
}
int mm;
for(int i=1;i<=31;i++){
if((1<<i)>=min1)
mm=i;
}
int ans = 0;
for (int i = mm+1; i >= 0; --i) {
//
// if((1<<(i+1))<min1){
// cout<<ans<<endl;
// return 0;
// }
int flag = 1;
for (int j = 1; j <= n && flag; ++j) {
int minn = choose[j] | (1 << i);
int maxx = choose[j] | ((1 << i+1) - 1);
if (minn > r[j] || maxx < l[j])
flag = 0;
}
if (flag) {
for (int j = 1; j <= n; ++j)
choose[j] |= 1 << i;
ans |= 1 << i;
}
else {
for (int j = 1; j <= n; ++j) {
int minn = choose[j] | (1 << i);
int maxx = choose[j] | ((1 << i+1) - 1);
if (minn <= r[j] && maxx >= l[j] && minn<= l[j])
choose[j] |= 1 << i;
}
}
}
cout<<ans<<endl;
}
int main ()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>T;
while (T--) {
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3588kb
input:
2 3 0 8 2 6 3 9 1 1 100
output:
0 100
result:
wrong answer 1st numbers differ - expected: '6', found: '0'