QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#145381 | #6655. 巧克力 | qzez# | WA | 1093ms | 3844kb | C++14 | 1.6kb | 2023-08-22 10:19:19 | 2023-08-22 10:19:20 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=60+5,M=N*4+5,K=31650,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(time(0));
ll n,m,k,p;
ll dp[N][2][2][2],tg[N][2][2][2];
ll dfs(int x,int y,int o1,int o2){
if(x<0) return o1&&o2&&!y;
if(tg[x][y][o1][o2]) return dp[x][y][o1][o2];
ll &ans=dp[x][y][o1][o2];tg[x][y][o1][o2]=1;
for(int i=0;i<8;i++)if(!((i&1)^(i>>1&1)^(i>>2&1)^(p>>x&1))){
if((i&1)>(k>>x&1)&&!o1) continue;
for(int j=0;j<2;j++){
if((i>>1&1)+(i>>2&1)+j<2*y||(i>>1&1)+(i>>2&1)+j>2*y+1) continue;
if((i>>1&1)+(i>>2&1)+j>2*y+(i&1)&&!o2) continue;
ans+=dfs(x-1,j,o1|((i&1)<(k>>x&1)),o2|((i>>1&1)+(i>>2&1)+j<2*y+(i&1)));
}
}
// cerr<<k<<' '<<x<<' '<<y<<' '<<o1<<' '<<o2<<' '<<ans<<'\n';
return ans;
}
ll calc(ll m){
Me(dp,0);Me(tg,0);k=m+1;
return dfs(60,0,0,0);
}
void Solve(){
int i,j;scanf("%lld%lld",&n,&m);
p=m;
if(n%4==0) p^=n;
else if(n%4==1) p^=n^(n-1);
else if(n%4==2) p^=n^(n-1)^(n-2);
if(!p) {puts("0");return;}
// cerr<<p<<'\n';
// cerr<<calc(4)<<'\n';
printf("%lld\n",(calc(n)+calc(m)-calc(m-1)+mod)%mod);
}
int main(){
int t;
scanf("%d",&t);
// t=1;
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1093ms
memory: 3844kb
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 2 2 2 1 1 0 4 4 0 4 4 6 2 3 2 2 2 4 0 5 5 0 6 5 7 6 0 0 -649542863 816081632 -754107351 810417181 -368768276 -446610041 346563231 585033078 350413035 -539315448 256773311 376732855 -870534439 268198252 974593262 569649682 480301360 477651660 -322770405 -314006649 84897229 5049619...
result:
wrong answer 39th numbers differ - expected: '617401866', found: '-649542863'