QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#587303 | #9378. Strange Binary | 2023_ljd | WA | 18ms | 3680kb | C++23 | 981b | 2024-09-24 19:17:16 | 2024-09-24 19:17:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std ;
#define int long long
void solve() {
int n , a[35] , b[35] ;
cin >> n ;
for(int i=0 ; i<=31 ; i++) {
b[i] = n&1 ;
n >>= 1 ;
}
if(!b[0] && !b[1]) {
cout << "NO" << endl ;
return ;
}
for(int l=0 , r=0 ; r<=31 ; l = r ) {
r = l ;
for(r = l ; r<=31 ; r++) {
if(b[r] == 1) {
a[r] = 1 ; break ;
}
a[r] = 0 ;
}
if(l==r) {
r++ ; continue ;
}
a[r-1] = 1 ;
for(int i=l-1 ; i<r-1 ; i++)
a[i] = -1 ;
}
cout << "YES" << endl ;
for(int i=0 ; i<=31 ; i++)
cout << a[i] << ' ' ;
cout << endl ;
}
signed main() {
ios::sync_with_stdio(false) ;
cin.tie(nullptr) , cout.tie(nullptr) ;
int t =1 ; cin >> t ;
while(t--) solve() ;
//system("pause") ;
return 0 ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3680kb
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: 3632kb
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: 18ms
memory: 3584kb
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 -1 1 -1 -...
result:
wrong answer Offend Limitation 3. (test case 10000)