QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#361053 | #8337. Counter Reset Problem | Core_65536 | WA | 0ms | 3728kb | C++20 | 995b | 2024-03-22 18:43:49 | 2024-03-22 18:43:50 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
void solve()
{
int x,y,k; cin>>x>>y>>k;
if(x>y) swap(x,y);
int len=0;
int tmp=k;
while(tmp!=0)
{
len++;
tmp=tmp>>1;
}
int xl,xr,yl,yr;
xl=x>>len; xr=x-(xl<<len);
yl=y>>len; yr=y-(yl<<len);
int m=3;
if(k==(1<<len)-1) m=2;
int t=m*(yl-xl-1);
int a=((~xr)>k)?3:2;
if(xr==((1<<len)-1)) a=1;
int b=(yr>k)?2:1;
if(yr==0) b=0;
int ans=t+a+b;
if(x==0) a=1;
if(y==0) b=0;
if(k==1||k==0) ans=(y-x);
int cnt=0;
for(int i=0;i<61;i++){
if(((x>>i)&1)!=((y>>i)&1)){
cnt+=1<<i;
}
}
if(cnt<=k) ans=1;
if(x==y) ans=0;
cout<<t<<" "<<a<<" "<<b<<endl;
cout<<ans<<endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int T=0; cin>>T;
while(T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3728kb
input:
2 19 23
output:
6 1 0 4 6 1 0 4
result:
wrong answer 1st numbers differ - expected: '51', found: '6'