QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#538129 | #9114. Black or White 2 | nhuang685 | WA | 176ms | 3628kb | C++23 | 2.5kb | 2024-08-31 04:08:48 | 2024-08-31 04:08:48 |
Judging History
answer
/**
* @author n685
* @brief
* @date 2024-08-26 21:09:43
*
*
*/
#include "bits/stdc++.h"
#ifdef LOCAL
#include "dd/debug.h"
#else
#define dbg(...) 42
#define dbg_proj(...) 420
#define dbg_rproj(...) 420420
void nline() {}
void bar() {}
void start_clock() {}
void end_clock() {}
#endif
namespace io {
template <class T> T read() {
T val;
if constexpr (std::is_array_v<T>) {
for (auto &v : val) {
v = read<T::value_type>();
}
} else {
std::cin >> val;
}
return val;
}
template <class T, class U, class... Args> std::tuple<T, U, Args...> read() {
T l = read<T>();
return std::tuple_cat(
std::tuple{std::move(l)}, std::tuple{read<U, Args...>()}
);
}
// for rv::iota | rv::transform
template <class T> T read_i(int /**/) { return read<T>(); }
template <class T, class U, class... Args>
std::tuple<T, U, Args...> read_i(int /**/) {
return read<T, U, Args...>();
}
} // namespace io
std::vector<std::vector<bool>> gen(int n, int m, int k) {
std::vector<std::vector<std::pair<int, int>>> loc(n + m - 1);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
loc[i + j].emplace_back(i, j);
}
}
std::vector ans(n, std::vector<bool>(m));
int mx = 0;
for (int i = 0; i < n + m - 1; ++i) {
if (k >= std::ssize(loc[i])) {
mx = i;
for (auto [a, b] : loc[i]) {
ans[a][b] = true;
}
k -= static_cast<int>(loc[i].size());
} else {
break;
}
}
for (int i = 0; i < n && k > 0; ++i) {
for (int j = 0; j < m && k > 0; ++j) {
if ((n - 1 - i) % 2 == 0 && (m - 1 - j) % 2 == 0 && i + j >= mx + 3) {
ans[i][j] = true;
--k;
}
}
}
dbg(k);
return ans;
}
void solve() {
const auto [n, m, k] = io::read<int, int, int>();
if (n == 2 && m == 2 && k == 2) {
std::cout << "10\n";
std::cout << "01\n";
return;
}
bool rot = n > m;
bool fl = k > n * m / 2;
std::vector<std::vector<bool>> ans =
gen(std::min(n, m), std::max(n, m), std::min(k, n * m - k));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
bool val = fl ^ (rot ? ans[j][i] : ans[i][j]);
std::cout << val;
}
std::cout << '\n';
}
}
int main() {
#ifndef LOCAL
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
#endif
int t;
std::cin >> t;
for (int i = 0; i < t; ++i) {
dbg(i + 1);
solve();
bar();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
input:
2 2 2 2 2 3 0
output:
10 01 000 000
result:
ok Output is valid. OK.
Test #2:
score: -100
Wrong Answer
time: 176ms
memory: 3628kb
input:
27520 2 2 0 2 2 1 2 2 2 2 2 3 2 2 4 2 3 0 2 3 1 2 3 2 2 3 3 2 3 4 2 3 5 2 3 6 3 2 0 3 2 1 3 2 2 3 2 3 3 2 4 3 2 5 3 2 6 3 3 0 3 3 1 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 3 3 8 3 3 9 2 4 0 2 4 1 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 2 4 7 2 4 8 3 4 0 3 4 1 3 4 2 3 4 3 3 4 4 3 4 5 3 4 6 3 4 7 3 4 8 3 4 9 3 4 10...
output:
00 00 10 00 10 01 01 11 11 11 000 000 100 000 100 001 110 100 011 110 011 111 111 111 00 00 00 10 00 00 10 00 01 11 10 00 01 11 10 01 11 11 11 11 11 000 000 000 100 000 000 100 000 001 110 100 000 110 100 001 001 011 110 001 011 111 011 111 110 011 111 111 111 111 111 0000 0000 1000 0000 1000 0001 1...
result:
wrong answer The number of black cell is not K