QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#759592#9346. Binary Numbers275307894a#WA 18ms8636kbC++141.9kb2024-11-18 10:19:522024-11-18 10:19:52

Judging History

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

  • [2024-11-18 10:19:52]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:8636kb
  • [2024-11-18 10:19:52]
  • 提交

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
#define eb emplace_back
#define all(x) x.begin(),x.end()
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>;
const int N=(1<<18)+5,M=N*4+5,K=1000+5,mod=1e8+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n,m,L[N],R[N];
ll f[N],dp[N];
int calc(int x,int y){
	for(int i=m-1;~i;i--) if((x>>i&1)^(y>>i&1)) return m-1-i;
	return m;
}
void Solve(){
	scanf("%d%d",&m,&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&L[i],&R[i]);
	fill(f,f+(1<<m+1),0);
	for(int i=1;i<=n;i++){
		for(int j=L[i];j<=R[i];j++){
			dp[j]=0;
			int d=calc(j,L[i]);
			int x=j+(1<<m);
			for(int h=m;h>m-d;h--){
				if(x>>h-1&1) dp[j]+=f[x>>h];
			}
			dp[j]%=mod;
			if(i==1) dp[j]++;
			dp[j]=dp[j]*j%mod;
			gdb(j,dp[j]);
		}
		for(int j=L[i];j<=R[i];j++){
			int x=j+(1<<m);
			int d=calc(j,R[i]);
			// gdb(j,d);
			for(int h=m;h>m-d;h--){
				if(~x>>h-1&1) (f[x>>h]+=dp[j])%=mod/*,gdb(x,h,j)*/;
			}
		}
		gdb(f[1],f[2],f[3],f[4],f[5],f[6],f[7]);
	}
	printf("%lld\n",accumulate(dp+L[n],dp+R[n]+1,0ll)%mod);
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

详细

Test #1:

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

input:

1
2 2
0 1
2 3

output:

5

result:

ok single line: '5'

Test #2:

score: -100
Wrong Answer
time: 18ms
memory: 8636kb

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:

821340
86974977
5535977
77381999
95528195
17640
37275888
89424209
9804655
72563923
88339137
23963353
2940
3950756
1
71756082
35415944
98160349
28
64318759

result:

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