QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#32669 | #2617. Browsing the Collection | Sorting# | WA | 1ms | 3676kb | C++20 | 962b | 2022-05-22 22:41:48 | 2022-05-22 22:41:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
ll l , r ;
const int mg=16;
bool check(ll l1,ll l2,ll len){
//cout << l1 << ' ' << l2 << ' ' << len << endl;
if(len==1){
int c1=__builtin_popcountll(l1);
int c2=__builtin_popcountll(l2);
return (c1%2==c2%2);
}
if(l1%2!=l2%2){
if(len>=4) return false;
for(int i=0; i<len ;i++){
if(!check(l1+i,l2+i,1)) return false;
}
return true;
}
if(l1%2==1) l1--,l2--,len++;
if(len%2==1) len++;
return check(l1/2,l2/2,len/2);
}
void solve(){
cin >> l >> r;
ll z=1;;
ll len=r-l+1;
while(z*mg<=len) z*=2;
for(ll l2=l%z; ;l2+=z){
if(check(l2,l,len)){
cout << l2 << '\n';
return;
}
}
}
int main(){
ios::sync_with_stdio(false);
int t;cin >> t;while(t--) solve();
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3676kb
input:
9 3 5 3 7 5 3 4 5 3 7 5 3 2 5 3 4 5 3 7 2 3 7 5 3 7 2 3 7
output:
3 3 0 2 3 0 2 0 0
result:
wrong answer 1st numbers differ - expected: '0', found: '3'