QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#644342#9378. Strange BinaryScene#WA 0ms3736kbC++141.0kb2024-10-16 13:24:512024-10-16 13:24:51

Judging History

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

  • [2024-10-16 13:24:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3736kb
  • [2024-10-16 13:24:51]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int read(){
	int ret=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
	while( isdigit(ch)){ret=(ret<<3)+(ret<<1)+(ch&15);ch=getchar();}
	return ret*f;
}
int T,n;
int a[40];
int main(){
	T=read();
	while(T--){
		n=read();
		for(int i=0;i<=31;++i) a[i]=0;
		for(int i=0;i<=31;++i){
			if(n&(1<<i)) a[i]=1;
		}
		int now=32;
		bool flg=1;
		while(now){
			now--;
			if(a[now]!=0) continue;
			if(now==0||a[now-1]!=0) continue;
			int ed=now-1;
			while(ed&&a[ed-1]==0) ed--;
			if(ed==0){
				flg=0;
				break;
			}
			if(a[ed-1]==1){
				a[now]=1;
				for(int i=now-1;i>=ed;--i){
					a[i]=-1;
				}
				a[ed-1]=-1;
			}else{
				a[now]=-1;
				for(int i=now-1;i>=ed;--i){
					a[i]=1;
				}
				a[ed-1]=1;
			}
			now=ed-1;
		}
		if(!flg){
			printf("NO\n");
		}else{
			for(int i=0;i<=31;++i){
				printf("%d",a[i]);
				if(i%8==7) putchar('\n');
				else putchar(' ');
			}
		}
	}	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3736kb

input:

3
0
3
5

output:

NO
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
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:

wrong answer Token parameter [name=checker] equals to "1", doesn't correspond to pattern "YES|NO" (test case 3)