QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#245116 | #6730. Coolbits | gzzz | WA | 199ms | 4980kb | C++20 | 869b | 2023-11-09 18:59:17 | 2023-11-09 18:59:24 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
ll n,l[maxn],r[maxn];
bool check(ll x){
for(int i=1;i<=n;i++){
if(!((1ll<<x)&r[i])) {
return false;
}
}
return true;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t;cin>>t;
while(t--){
cin>>n;
for(int i=1;i<=n;i++){
cin>>l[i]>>r[i];
}
ll ans=0;
bool flag=true;
for(int i=30;i>=0&&flag;i--){
if(check(i)){
ans+=(1ll<<i);
for(int j=1;j<=n;j++){
l[j]=max((1ll<<i),l[j]);
}
}
else {
for(int j=1;j<=n;j++){
if((1ll<<i)&r[j]){
for(int k=0;k<i;k++){
r[j]|=(1ll<<k);
}
}
}
}
for(int j=1;j<=n&&flag;j++){
if(l[j]>r[j]) {
flag=false;
}
}
}
cout<<ans<<"\n";
}
}
/*
1
2
1024 1025
1024 1026
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3420kb
input:
2 3 0 8 2 6 3 9 1 1 100
output:
6 100
result:
ok 2 number(s): "6 100"
Test #2:
score: -100
Wrong Answer
time: 199ms
memory: 4980kb
input:
1117 74 234256176 451122435 614716780 701954053 31102604 284818525 528763990 809400397 40637446 612671528 329403504 936190213 112402633 729525189 248142852 481053286 30877745 700834811 529884578 749041634 146522084 758550567 934650972 996096650 538751855 856147351 170918541 975066425 253153230 35361...
output:
93281727 178897983 605885728 115213978 156709101 48236211 88265286 150841039 171994003 310407464 144137157 42855333 68315319 120900807 114930940 76692399 434316427 99517528 55894474 135007650 271902974 83920537 205049062 86118041 405496044 59618653 55717970 75700110 312760218 91784122 57712698 24424...
result:
wrong answer 1st numbers differ - expected: '29882460', found: '93281727'