QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#581565 | #9378. Strange Binary | Wood# | WA | 0ms | 3552kb | C++23 | 1.0kb | 2024-09-22 13:23:25 | 2024-09-22 13:23:32 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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)