QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#275341 | #6655. 巧克力 | rageOfThunder# | WA | 1648ms | 3680kb | C++14 | 2.4kb | 2023-12-04 17:00:26 | 2023-12-04 17:00:27 |
Judging History
answer
//-DYUNQIAN -std=c++14 -O2 -Wall
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define fi first
#define se second
#define mk make_pair
using namespace std;
inline int read(){
int x=0,f=1;char c=getchar();
for(;(c<'0'||c>'9');c=getchar()){if(c=='-')f=-1;}
for(;(c>='0'&&c<='9');c=getchar())x=x*10+(c&15);
return x*f;
}
const int mod=1e9+7;
int ksm(int x,int y,int p=mod){
int ans=1;
for(int i=y;i;i>>=1,x=1ll*x*x%p)if(i&1)ans=1ll*ans*x%p;
return ans%p;
}
int inv(int x,int p=mod){return ksm(x,p-2,p)%p;}
mt19937 rnd(time(0));
int randint(int l,int r){return rnd()%(r-l+1)+l;}
void add(int &x,int v){x+=v;if(x>=mod)x-=mod;}
void Mod(int &x){if(x>=mod)x-=mod;}
void Assert(bool c,int L=0){if(!c){cout<<"Assertion Failed at "<<L<<endl;exit(0);}}
void cmax(int &x,int v){x=max(x,v);}
void cmin(int &x,int v){x=min(x,v);}
int f[2][4][3][2];
signed main(void){
#ifdef YUNQIAN
freopen("in.in","r",stdin);
#endif
auto F=[&](int n,int S){
if(n<=0)return 0ll;
memset(f,0,sizeof(f));
vector<int>vals,tv;
// cout<<"get "<<n<<endl;
while(n)vals.emplace_back(n%2),n/=2;
while(S)tv.emplace_back(S%2),S/=2;tv.resize(vals.size());
// cout<<"vals = ";for(int x:vals)cout<<x<<" ";puts("");
int cur=0;f[cur][0][1][0]=1;
for(int i=0;i<vals.size();i++){
memset(f[cur^1],0,sizeof(f[cur^1]));
for(int j=0;j<=3;j++)for(int k=0;k<=2;k++)for(int l=0;l<=1;l++)if(f[cur][j][k][l]){
// cout<<"f "<<i-1<<" "<<j<<" "<<k<<" "<<l<<" = "<<f[cur][j][k][l]<<endl;
for(int a=0;a<=1;a++)for(int b=0;b<=1;b++)for(int c=0;c<=1;c++)if(a^b^((a+b+c+j)%2)==tv[i]){
int tj=(j+a+b+c)/2;
int tk=k,v=(j+a+b+c)%2;
if(v==1&&vals[i]==0)tk=2;// >
if(v==0&&vals[i]==1)tk=0;// <
int tl=(l|(c==1));
add(f[cur^1][tj][tk][tl],f[cur][j][k][l]);
}
}
cur^=1;
}
// for(int j=0;j<=3;j++)for(int k=0;k<=2;k++)for(int l=0;l<=1;l++)if(f[cur][j][k][l])cout<<"f "<<vals.size()<<" "<<j<<" "<<k<<" "<<l<<" = "<<f[cur][j][k][l]<<endl;
int ans=0;
for(int j=0;j<=0;j++)for(int k=0;k<=1;k++)for(int l=1;l<=1;l++)add(ans,f[cur][j][k][l]);
return ans;
};
int tt=read();while(tt--){
int n=read(),m=read();
int S=m;
if(n%4==0)S^=n;
if(n%4==1)S^=n^(n-1);
if(n%4==2)S^=n^(n-1)^(n-2);
if(n%4==3)S^=n^(n-1)^(n-2)^(n-3);// = 0
cout<<F(n,S)+F(m,S)-F(m-1,S)<<"\n";
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1648ms
memory: 3680kb
input:
50000 0 0 0 1 0 2 0 3 0 4 0 5 1 0 1 1 1 2 1 3 1 4 1 5 2 0 2 1 2 2 2 3 2 4 2 5 3 0 3 1 3 2 3 3 3 4 3 5 4 0 4 1 4 2 4 3 4 4 4 5 5 0 5 1 5 2 5 3 5 4 5 5 0 2000000013 3 2000000013 960420868510113883 392659194919473988 668803384430801620 162045456939453012 617795168362576047 722239203838631701 6050650100...
output:
0 1 1 2 2 3 1 0 2 2 0 2 2 1 1 0 2 5 0 4 4 6 2 6 2 3 3 6 0 5 5 0 5 5 4 6 0 3 617401866 621360288 788974705 719403921 388746468 643862746 -334368738 107105273 892988359 21085898 -375727873 736064559 355167623 -446164613 311484988 140174338 1095593489 922332339 154447963 420109896 648989232 -193462879 ...
result:
wrong answer 11th numbers differ - expected: '2', found: '0'