QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#587313#9378. Strange Binary2023_ljdWA 22ms3708kbC++23990b2024-09-24 19:23:112024-09-24 19:23:12

Judging History

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

  • [2024-09-24 19:23:12]
  • 评测
  • 测评结果:WA
  • 用时:22ms
  • 内存:3708kb
  • [2024-09-24 19:23:11]
  • 提交

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<=30 ; i++)
        cout << a[i] << ' ' ;
    cout << a[31] << 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: 3576kb

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: 3708kb

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: 22ms
memory: 3640kb

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

result:

wrong answer Offend Limitation 3. (test case 10000)