QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#32669#2617. Browsing the CollectionSorting#WA 1ms3676kbC++20962b2022-05-22 22:41:482022-05-22 22:41:49

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-22 22:41:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3676kb
  • [2022-05-22 22:41:48]
  • 提交

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();
}

Details

Tip: Click on the bar to expand more detailed information

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'