QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#625110#9346. Binary Numbersucup-team4352#WA 8ms8016kbC++231.1kb2024-10-09 17:29:222024-10-09 17:29:23

Judging History

你现在查看的是最新测评结果

  • [2024-10-09 17:29:23]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:8016kb
  • [2024-10-09 17:29:22]
  • 提交

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>l[i-1])s[j]-=s[now-1];
			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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7756kb

input:

1
2 2
0 1
2 3

output:

5

result:

ok single line: '5'

Test #2:

score: -100
Wrong Answer
time: 8ms
memory: 8016kb

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:

187110
423187288
782968961
484643810
283585213
5040
7817040
741577230
687472528
802613664
991705557
477903970
1050
320087304
1
401102788
485868714
994307213
28
964435189

result:

wrong answer 1st lines differ - expected: '430920', found: '187110'