QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#528063 | #2808. Gardening | nhuang685# | 0 | 10ms | 3724kb | C++20 | 1.5kb | 2024-08-23 06:18:17 | 2024-08-23 06:18:17 |
Judging History
answer
#include <bits/stdc++.h>
void solve() {
int n, m, k;
std::cin >> n >> m >> k;
if (n % 2 != 0 || m % 2 != 0) {
std::cout << "NO\n";
return;
}
if (n == 2) {
if (k != n * m / 4) {
std::cout << "NO\n";
} else {
std::cout << "YES\n";
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
std::cout << j / 2 + 1 << ' ';
}
std::cout << '\n';
}
}
return;
}
int mi = (n - 2) * (m - 2) / 4 + 1;
int mx = n * m / 4;
if (k < mi || k == mx - 1) {
std::cout << "NO\n";
return;
}
std::cout << "YES\n";
if (k == mx) {
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
std::cout << 1 + i / 2 + j / 2 * 2 << ' ';
}
std::cout << '\n';
}
return;
}
int bound = 2 * (m / 2 - (k - mi)) - 1;
int num1 = 1 + (n - 2) * (bound - 1) / 4;
std::cerr << bound << '\n';
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
if (j <= bound) {
if (i == 0 || i == n - 1 || j == 0 || j == bound) {
std::cout << 1 << ' ';
} else {
std::cout << 2 + (j - 1) / 2 << ' ';
}
} else {
std::cout << num1 + 1 + (j - bound - 1) / 2 * 2 + i / 2 << ' ';
}
}
std::cout << '\n';
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
while ((t--) != 0) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 10ms
memory: 3588kb
input:
28119 2 4 2 2 2 1 4 2 2 2 2 1 2 2 1 2 2 3 2 4 2 4 4 2 2 2 2 2 2 2 4 4 3 2 2 1 4 2 2 4 4 4 4 2 2 2 4 2 2 2 2 2 2 2 2 2 1 2 2 1 2 2 1 2 2 1 2 2 2 2 2 1 2 4 2 2 2 1 2 2 1 2 2 1 4 2 2 2 2 2 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 4 2 7 2 2 1 2 4 2 2 2 1 4 2 2 2 4 2 2 2 1 2 4 4 2 2 1 2 2 1 2 2 1 4 2 2 2 2 2 2 2 1 ...
output:
YES 1 1 2 2 1 1 2 2 YES 1 1 1 1 YES 1 1 1 1 2 2 2 2 YES 1 1 1 1 YES 1 1 1 1 NO YES 1 1 2 2 1 1 2 2 YES 1 1 1 1 1 2 2 1 1 2 2 1 1 1 1 1 NO NO NO YES 1 1 1 1 YES 1 1 1 1 2 2 2 2 YES 1 1 3 3 1 1 3 3 2 2 4 4 2 2 4 4 YES 1 1 1 1 2 2 2 2 YES 1 1 2 2 1 1 2 2 NO NO YES 1 1 ...
result:
wrong answer Incorrect output (test case 36)
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 1ms
memory: 3548kb
input:
311 2 2 1 12 12 14 6 6 6 40 40 297 28 28 82 30 30 74 4 4 10 38 38 210 6 6 4 42 42 365 8 8 11 16 16 30 6 6 7 22 22 38 10 10 5 2 2 2 12 12 19 16 16 52 28 28 124 26 26 92 2 2 2 28 28 25 20 20 19 18 18 43 4 4 3 30 30 78 26 26 130 18 18 58 26 26 59 6 6 4 10 10 6 14 14 34 18 18 184 12 12 108 18 18 35 30 3...
output:
YES 1 1 1 1 NO YES 1 1 1 1 4 4 1 2 2 1 4 4 1 2 2 1 5 5 1 2 2 1 5 5 1 2 2 1 6 6 1 1 1 1 6 6 NO NO NO YES 7 7 9 9 7 7 9 9 8 8 10 10 8 8 10 10 NO NO NO YES 1 1 1 1 1 1 8 8 1 2 2 3 3 1 8 8 1 2 2 3 3 1 9 9 1 2 2 3 3 1 9 9 1 2 2 3 3 1 10 10 1 2 2 3 3 1 10 10 1 2 2 3 3 1 11 11 1 1 1 1 1 ...
result:
wrong answer Incorrect output (test case 2)
Subtask #5:
score: 0
Wrong Answer
Test #19:
score: 0
Wrong Answer
time: 6ms
memory: 3724kb
input:
310 44 2 22 36 8 195 2 2 4 2 50 61 12 42 275 4 4 5 26 30 416 24 20 252 20 32 498 30 30 130 32 48 1153 46 16 574 4 40 89 6 28 64 10 16 9 18 42 152 4 14 1 6 50 280 10 10 87 44 24 395 2 2 4 40 46 273 34 34 607 22 22 300 40 40 1166 10 48 211 42 22 334 6 10 20 38 38 189 6 10 36 14 14 33 44 48 1518 32 18 ...
output:
YES 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 11 11 11 11 12 12 12 12 13 13 13 13 14 14 14 14 15 15 15 15 16 16 16 16 17 17 17 17 18 18 18 18 19 19 19 19 20 20 20 20 21 21 21 21 22 22 22 22 YES -2100 -2100 -2098 -2...
result:
wrong answer Incorrect output (test case 2)
Subtask #6:
score: 0
Skipped
Dependency #1:
0%