QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#588824#9378. Strange BinaryHide_In_The_ShadowWA 7ms3848kbC++231.5kb2024-09-25 14:45:582024-09-25 14:45:58

Judging History

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

  • [2024-09-25 14:45:58]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3848kb
  • [2024-09-25 14:45:58]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define fio std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
template<typename T>inline void read(T &x){
	x=0;
	char c=getchar();
	T ret=0;
	while(!isdigit(c))ret|=!(c^'-'),c=getchar();
	while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
	if(ret)x=(~x)+1;
	return;
}
template<typename T>inline void print(T x){
	if(x<0)putchar('-'),x=(~x)+1;
	if(x>9)print(x/10);
	putchar((x-x/10*10)^48);
	return;
}
template<typename T>inline void wr1(T x){
	print(x);
	putchar(' ');
	return;
}
template<typename T>inline void wr2(T x){
	print(x);
	putchar('\n');
	return;
}
int t,n;
stack<int>out;
int main(){
	read(t);
    while(t--){
        read(n);
        if(n==0||((n&(-n))>2)){
            puts("NO");
            continue;
        }
        puts("YES");
        bool pre=0;
        for(int i=31;i>=0;--i){
            if(!n){
                out.push(0);
                continue;
            }
            if(pre){
                out.push(-1);
                if(1&(n>>i)){
                    pre=0;
                    n^=1<<i;
                }
            }
            else{
                out.push(1);
                if(!(1&(n>>i))){
                    pre=1;
                }
            }
        }
        while(out.size()){
            wr1(out.top());
            if((out.size()-1)%8==0)putchar('\n');
            out.pop();
        }
    }
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3848kb

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 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! (3 test cases)

Test #2:

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

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: -100
Wrong Answer
time: 7ms
memory: 3612kb

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 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 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 -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 
NO
YES
1 -1 -1 -1 -1 -1 1 1 
-1...

result:

wrong answer Offend Limitation 3. (test case 10000)