QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#589316 | #9378. Strange Binary | Ponderous | WA | 0ms | 3720kb | C++11 | 1.4kb | 2024-09-25 17:09:10 | 2024-09-25 17:09:12 |
Judging History
answer
#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair<int,int> pii;
using i64 = long long;
using u64 = unsigned long long;
const int N = 1e5 + 10;
int a[32];
void init()
{
for(int i = 0; i < 31; i ++) a[i] = -1;
a[31] = 1;
}
void print()
{
cout << "YES" << "\n";
for(int i = 0; i <= 31; i ++)
{
cout << a[i] << " ";
if((i + 1) % 8 == 0) cout << "\n";
}
}
void solve()
{
init();
i64 n;
cin >> n;
if(n == 0 || n % 4 == 0)
{
cout << "NO" << "\n";
return ;
}
n --;
int flag = 0;
for(int i = 30; ~i; i --)
{
i64 k = (1 << i);
if(n < k) continue;
if(n >= 2 * k)
{
flag = 1;
n -= 2 * k;
a[i] = 1;
}
else if(flag && n >= k)
{
n -= k;
a[i] = 0;
}
}
if(n) cout << "NO" << "\n";
else
{
int ok = 1;
for(int i = 0; i < 31; i ++)
if(a[i] == 0 && a[i + 1] == 0)
{
ok = 0;
break;
}
if(ok) print();
else cout << "NO" << endl;
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
cin >> T;
while(T --) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
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:
ok Accepted! (3 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3592kb
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: -100
Wrong Answer
time: 0ms
memory: 3720kb
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:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO ...
result:
wrong answer Jury's answer is YES, but Participant's answer is NO. (test case 10000)