QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#584021 | #9346. Binary Numbers | kevinshan# | WA | 24ms | 48960kb | C++14 | 2.0kb | 2024-09-23 04:07:24 | 2024-09-23 04:07:24 |
Judging History
answer
#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
const int MO=100000007;
int h[2222222];
int N,m,L[2222222],R[2222222];
int f[140000][18][18];
int F(int x,int y){
return m-1-h[x^y];
}
void doit(){
scanf("%d%d",&m,&N);
FOR(i,1,N){
scanf("%d%d",&L[i],&R[i]);
// FOR(j,L[i],R[i])
// bl[j]=i;
}
FOR(i,0,N)
FOR(j,0,m)
FOR(k,0,m)
f[i][j][k]=0;
f[0][m][0]=1;
FOR(i,0,N-1)
FOR(j1,0,m)
FOR(j2,0,m){
//f[i][j]
if (f[i][j1][j2]==0) continue;
if (i==1 && j1==2 && j2==0){
int tt=1;
}
FOR(k,L[i+1],R[i+1])
if (i==0 || (F(k,R[i]) <= j1 && F(k,L[i+1]) >= j2)){
int p1 = m-1-h[k^R[i+1]];
int p2;
if (i<N-1) p2 = m-1-h[k^(1+R[i+1])];
else p2 = 0;
(f[i+1][p1][p2]+=1ll*f[i][j1][j2]*k%MO)%=MO;
// if ()
// //R[i] qian j
// int t = h[R[i]^k];
// bool ok =0;
// if (t<m-j)
// ok=1;
// else{
// int ll = ((R[i]>>t)<<t);
// int rr = (((R[i]>>t)+1)<<t)-1;
// if (max(ll,L[i+1])>min(rr,R[i+1]))
// ok=1;
// }
// if (ok)
// (f[i+1][m-1-h[k^R[i+1]]]+=f[i][j] * k)%=MO;
}
}
long long ans=0;
FOR(j1,0,m) FOR(j2,0,m)
(ans+=f[N][j1][j2])%=MO;
printf("%d",(int)ans);
}
int main(){
m=17;
h[0]=-1;
FOR(i,1,(1<<m)-1)
FORD(j,m-1,0)
if ((i>>j)&1){
h[i]=j;
break;
}
int T;
scanf("%d",&T);
while (T--) doit();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 10028kb
input:
1 2 2 0 1 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: -100
Wrong Answer
time: 24ms
memory: 48960kb
input:
20 4 6 0 1 2 3 4 6 7 7 8 11 12 15 9 39 0 31 32 47 48 51 52 63 64 87 88 92 93 95 96 127 128 143 144 159 160 167 168 175 176 191 192 207 208 255 256 263 264 271 272 283 284 287 288 289 290 295 296 303 304 319 320 351 352 357 358 367 368 375 376 383 384 391 392 399 400 403 404 407 408 415 416 443 444 4...
output:
4309202765175780424846877167144008233504028188720873858312833065791763968656974862319390622687359826711686720548893476832017902854705494
result:
wrong answer 1st lines differ - expected: '430920', found: '430920276517578042484687716714...6720548893476832017902854705494'