QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#580480 | #9378. Strange Binary | jayket | AC ✓ | 12ms | 3692kb | C++23 | 1.3kb | 2024-09-21 22:05:00 | 2024-09-21 22:05:02 |
Judging History
answer
#include<bits/stdc++.h>
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f64 = long double;
using i128 = __int128_t;
using f128 = __float128;
#ifndef ONLINE_JUDGE
#include "algo/debug.hpp"
#else
#define debug(...) (void)42
#endif
template<class T>
constexpr void chmax(T& x, T y) {
if (y > x) {
x = y;
}
}
template<class T>
constexpr void chmin(T& x, T y) {
if (y < x) {
x = y;
}
}
auto main() ->int32_t {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout << std::fixed << std::setprecision(13);
auto solve = [&]() {
int x;
std::cin >> x;
std::array<int, 32>f {};
for (int i = 0; i <= 31; i += 1) {
f[i] = (x >> i & 1);
}
for (int i = 0; i <= 31; i += 1) {
if (f[i] == 1) {
int j = i + 1;
while (j <= 31 and f[j] == 0) {
j += 1;
}
j -= 1;
for (int k = i; k <= j; k += 1) {
f[k] = -1;
}
f[j] = 1;
i = j;
}
}
for (int i = 0; i <= 30; i += 1) {
if (f[i] == 0 and f[i + 1] == 0) {
std::cout << "NO\n";
return ;
}
}
std::cout << "YES\n";
for (int i = 0; i < 4; i += 1) {
for (int j = 0; j < 8; j += 1) {
std::cout << f[i * 8 + j] << " \n"[j == 7];
}
}
};
int t;
std::cin >> t;
while (t--) {
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
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: 3688kb
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: 3692kb
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 -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 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 -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 NO YES 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1...
result:
ok Accepted! (10000 test cases)
Extra Test:
score: 0
Extra Test Passed