QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#580209#9378. Strange BinaryevilboyWA 0ms3484kbC++201.1kb2024-09-21 20:31:352024-09-21 20:31:35

Judging History

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

  • [2024-09-21 20:31:35]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3484kb
  • [2024-09-21 20:31:35]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;

void solve()
{
    int n;
    cin >> n;
    if(n == 0 || (n & -n) >= 4){
        cout << "NO\n";
        return;
    }

    vector<int> one;
    for(int i = 0; i < 32; i++)
        if((n >> i) & 1)
            one.push_back(i);
    vector<int> ans(32, 0);
    for(int i = 0; i < one.size(); i++)
    {
        int l = one[i], r = i + 1 < one.size() ? one[i + 1] : 31;
        ans[r] = 1;
        for(int j = l; j < r; j++)
            ans[j] = -1;
    }
    
    cout << "YES\n";
    for(int i = 0; i < 32; i++)
        cout << ans[i] << " \n"[(i + 1) % 8 == 0];
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T = 1;
    cin >> T;
    while(T --)
        solve();
    
    return 0;
}

/*
3
0
3
5

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
*/

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3484kb

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:

wrong answer Offend Limitation 3. (test case 3)