QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#580209 | #9378. Strange Binary | evilboy | WA | 0ms | 3484kb | C++20 | 1.1kb | 2024-09-21 20:31:35 | 2024-09-21 20:31:35 |
Judging History
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)