QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#145382 | #6655. 巧克力 | qzez# | WA | 1105ms | 3980kb | C++14 | 1.6kb | 2023-08-22 10:19:40 | 2023-08-22 10:19:42 |
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%mod;
}
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';
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1105ms
memory: 3980kb
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 226469452 182117731 362776123 896740888 710789400 366245527 346563231 760288229 644559697 53105385 256773311 978331524 717868483 268198252 708277827 479456706 330305270 477651660 517888377 279307741 193992143 7638836 5359819...
result:
wrong answer 39th numbers differ - expected: '617401866', found: '226469452'