QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#588925 | #9378. Strange Binary | Hide_In_The_Shadow | WA | 0ms | 3840kb | C++23 | 1.6kb | 2024-09-25 15:14:46 | 2024-09-25 15:14:50 |
Judging History
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);
wr2(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;
}
else{
n^=1<<i;
}
}
}
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: 0
Wrong Answer
time: 0ms
memory: 3840kb
input:
3 0 3 5
output:
0 NO 3 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 5 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:
wrong answer Token parameter [name=checker] equals to "0", doesn't correspond to pattern "YES|NO" (test case 3)