QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#601903#9378. Strange BinaryZpair#AC ✓15ms3944kbC++20835b2024-09-30 15:36:232024-09-30 15:36:24

Judging History

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

  • [2024-09-30 15:36:24]
  • 评测
  • 测评结果:AC
  • 用时:15ms
  • 内存:3944kb
  • [2024-09-30 15:36:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef unsigned int u32;
int bit[40],ans[40];
void solve(){
	u32 x;scanf("%u",&x);
	for(int i=0;i<=31;++i){
		if((x>>i)&1)bit[i]=1;
		else bit[i]=0;
	}
	for(int i=0;i<=31;++i)
		ans[i]=0;
	int cnt=0;
	for(int i=31;i>=0;--i){
		if(bit[i]==1){
			if(cnt>=2){
				ans[i+cnt]=1;
				for(int j=i+cnt-1;j>=i;--j)
					ans[j]=-1;
			}
			else ans[i]=1;
			cnt=0;
		}
		else cnt++;
	}
	if(cnt>=2)
		puts("NO");
	else{
		puts("YES");
		for(int i=0;i<=7;++i)
			printf("%d ",ans[i]);
		printf("\n");
		for(int i=8;i<=15;++i)
			printf("%d ",ans[i]);
		printf("\n");
		for(int i=16;i<=23;++i)
			printf("%d ",ans[i]);
		printf("\n");
		for(int i=24;i<=31;++i)
			printf("%d ",ans[i]);
		printf("\n");
	}
}
int main(){
	int T;cin>>T;
	while(T--)solve();
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0
3
5

output:

NO
YES
1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 1 
YES
1 0 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 1 

result:

ok Accepted! (3 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

2
0
1073741823

output:

NO
YES
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 1 1 1 1 -1 -1 1 

result:

ok Accepted! (2 test cases)

Test #3:

score: 0
Accepted
time: 15ms
memory: 3884kb

input:

10000
324097321
555675086
304655177
991244276
9980291
383616352
1071036550
795625380
682098056
68370721
969101726
685975156
973896269
354857775
196188000
606494155
754416123
467588829
495704303
558090120
618002000
491488050
741575237
9937018
10028830
140094825
652839595
357724903
516690123
817724271...

output:

YES
-1 -1 1 1 0 -1 -1 1 
1 0 1 0 1 0 1 0 
-1 -1 -1 1 1 0 1 0 
1 -1 -1 1 -1 -1 -1 1 
YES
0 1 1 -1 -1 1 1 1 
1 0 1 1 0 1 1 1 
0 1 1 1 -1 -1 -1 1 
-1 -1 -1 -1 1 -1 -1 1 
YES
-1 -1 1 -1 -1 1 1 0 
1 1 0 1 0 1 0 -1 
-1 -1 1 1 0 -1 -1 -1 
1 -1 -1 1 -1 -1 -1 1 
NO
YES
1 -1 -1 -1 -1 -1 1 1 
-1 -1 1 -1 -1 1 -...

result:

ok Accepted! (10000 test cases)

Extra Test:

score: 0
Extra Test Passed