QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#580840 | #9378. Strange Binary | JOFISH | WA | 0ms | 3656kb | C++23 | 864b | 2024-09-22 00:17:59 | 2024-09-22 00:18:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int arr[32];
vector<int> chances;
bool flag = 1;
int T;
LL n, Z;
int main() {
cin>>T;
while(T--) {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
chances.clear();
memset(arr, -1, sizeof arr);
arr[31] = 1;
cin>>n;
if (!n) {
cout<<"NO\n";
continue;
}
Z = n - 1;
for (LL i =1, j = 0; i<=Z; i<<=1, j++)
if (Z&i) chances.push_back(j);
for (int i=chances.size()-1 ; ~i && flag; i--) {
if (chances[i] == 0 && arr[0] != -1) flag = 0;
if (chances[i] == chances[i+1] + 1) arr[chances[i]-1] = 1;
else if (arr[chances[i]] != -1) arr[chances[i]-1] = 1;
else arr[chances[i]] = 0;
}
cout<<(flag ? "YES" : "NO")<<"\n";
for (int i=0; i<32; i++)
cout<<arr[i]<<" \n"[(i+1)%8 == 0];
cout<<"\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
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 0 -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: -100
Wrong Answer
time: 0ms
memory: 3588kb
input:
2 0 1073741823
output:
NO YES -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1
result:
wrong answer Offend Limitation 2. (test case 2)