QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#625085 | #9346. Binary Numbers | ucup-team4352# | WA | 10ms | 8000kb | C++23 | 1.1kb | 2024-10-09 17:24:10 | 2024-10-09 17:24:12 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define lowbit(x) (x&-x)
#define log(x) (31^__builtin_clz(x))
using namespace std;
const int p=1e9+7;
int l[1000005],r[1000005];
int s[1000005];
inline int calc(int x,int y){
int tmp=x^y;
for(int i=20;i>=0;i--){
if(tmp>>i&1)return 20-i;
}
return 21;
}
void solve(){
int m,n;
cin>>m>>n;
for(int i=1;i<=n;i++){
cin>>l[i]>>r[i];
}
for(int i=0;i<(1<<m);i++)s[i]=0;
for(int i=l[1];i<=r[1];i++){
s[i]=i+s[i-1];
if(s[i]>=p)s[i]-=p;
}
for(int i=2;i<=n;i++){
int now=l[i]-1;
for(int j=l[i];j<=r[i];j++){
while(now>l[i-1]&&calc(now-1,l[i])<=calc(i,l[i])&&calc(now-1,r[i-1])>=calc(i,r[i-1]))now--;
s[j]=s[r[i-1]];
if(now>0)s[j]-=s[now];
if(s[j]<0)s[j]+=p;
}
s[l[i]]=1ll*s[l[i]]*l[i]%p;
for(int j=l[i]+1;j<=r[i];j++){
s[j]=(1ll*s[j]*j+s[j-1])%p;
}
}
// for(int i=0;i<(1<<m);i++)cout<<s[i]<<"\n";
cout<<s[(1<<m)-1]<<"\n";
}
int main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t=1;
cin>>t;
while(t--)solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7748kb
input:
1 2 2 0 1 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: -100
Wrong Answer
time: 10ms
memory: 8000kb
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:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 28 0
result:
wrong answer 1st lines differ - expected: '430920', found: '0'