QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#580867 | #9378. Strange Binary | JOFISH | AC ✓ | 12ms | 3624kb | C++23 | 883b | 2024-09-22 00:26:37 | 2024-09-22 00:26:43 |
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() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin>>T;
while(T--) {
flag = 1;
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 && flag; i++)
cout<<arr[i]<<" \n"[(i+1)%8 == 0];
cout<<"\n";
}
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
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: 0
Accepted
time: 0ms
memory: 3612kb
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: 0
Accepted
time: 12ms
memory: 3560kb
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 0 -1 0 -1 -1 0 -1 0 -1 0 -1 0 -1 0 -1 -1 -1 0 -1 0 1 1 -1 -1 -1 0 -1 -1 1 YES 0 1 1 -1 -1 1 1 1 -1 1 1 -1 1 1 1 -1 1 1 1 1 -1 -1 -1 -1 0 -1 -1 -1 -1 0 -1 1 YES -1 -1 -1 0 -1 -1 0 1 1 -1 -1 0 -1 0 -1 0 -1 -1 -1 0 -1 0 -1 -1 -1 0 -1 -1 0 -1 -1 1 NO YES 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 0 ...
result:
ok Accepted! (10000 test cases)
Extra Test:
score: 0
Extra Test Passed