QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#580585 | #9378. Strange Binary | kalikari | WA | 31ms | 3780kb | C++17 | 1.3kb | 2024-09-21 22:35:18 | 2024-09-21 22:35:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
/*
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
*/
typedef long long LL;
#define int long long
#define ld long double
//#define INT __int128
const LL INF = 0x3f3f3f3f3f3f3f3f;
typedef unsigned long long ULL;
typedef pair<long long, long long> PLL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const ld eps = 1e-12;
const int N = 1e5 + 10, M = N + 10, K = N;
int n;
void solve(){
cin>>n;
int cn=0;
for(int i=31;i>=0;i--){
if(n>>i&1)cn++;
}
if(cn<=1){
cout<<"NO"<<endl;
return ;
}
n--;
std::vector<int> v(32,-1);
// for(int i=31;i>=0;i--){
// if(n>>i&1){
// if(i>0)
// v[i-1]=1;
// else
// v[i]=0;
// }
// }
bool fg=0;
for(int i=0;i<32;i++){
if(n>>i&1){
if(i>0){
if(v[i-1]==0){
fg=1;
break;
}
v[i-1]=1;
}
else{
if(v[i-1]==0){
fg=1;
break;
}
v[i]=0;
}
}
}
v[31]=1;
cout<<"YES"<<endl;
for(int i=0;i<32;i++){
if(i%8==0&&i!=0)cout<<endl;
cout<<v[i]<<" ";
}
cout<<endl;
}
signed main(){
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
int T=1,cas=1;
cin>>T;
while(T--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3552kb
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: 3780kb
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: 31ms
memory: 3780kb
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 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 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 0 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
wrong answer Offend Limitation 3. (test case 10000)