QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#581565#9378. Strange BinaryWood#WA 0ms3552kbC++231.0kb2024-09-22 13:23:252024-09-22 13:23:32

Judging History

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

  • [2024-09-22 13:23:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-09-22 13:23:25]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> a(32);
    for (int i = 0; i < 30; i++) {
        a[i] = (n >> i & 1);
    }

    for (int i = 0; i < 31; i++) {
        if (a[i] == 2) {
            a[i] = 0;
            a[i + 1] += 1;
        } else if (a[i] == 1 && a[i + 1] == 1) {
            a[i] = -1;
            a[i + 2] += 1;
        } 
    }

    for (int i = 0; i < 31; i++) {
        if (a[i] == 1 && a[i + 1] == 0) {
            a[i] = -1;
            a[i + 1] = 1;
        }
    }

    for (int i = 0; i < 31; i++) {
        if (a[i] == 0 && a[i + 1] == 0) {
            std::cout << "NO\n";
            return;
        }
    }

    std::cout << "YES\n";
    for (int i = 0; i < 32; i++) {
        std::cout << a[i] << " \n"[i % 8 == 7];
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int T;
    std::cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
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:

wrong answer Offend Limitation 3. (test case 3)