#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t;
cin >> t;
while(t--) {
int n, m, k;
cin >> n >> m >> k;
if(n % 2 == 1 || m % 2 == 1) {
cout << "NO\n";
continue;
}
if(n == 2) {
if(k == m/2) {
cout << "YES\n";
for(int i = 0; i < m; i++) cout << i/2+1 << " ";
cout << '\n';
for(int i = 0; i < m; i++) cout << i/2+1 << " ";
cout << '\n';
} else cout << "NO\n";
} else {
if(k < m/2 || k == m-1 || k > m) cout << "NO\n";
else {
cout << "YES\n";
vector<int> v;
int cur = m-k;
if(cur % 2 == 1) {
v.push_back(6);
cur -= 3;
}
for(int i = 0; i < cur/2; i++) {
v.push_back(4);
}
cur = 0;
for(int i : v) cur += i;
for(int i = 0; i < m-cur; i+=2) v.push_back(2);
int cols = 1;
vector<int> first, sec, thi;
for(int i : v) {
for(int j = 0; j < i; j++) {
cout << cols << " ";
first.push_back(cols);
}
cols++;
}
cout << '\n';
cur = 0;
for(int i : v) {
cout << first[cur] << " ";
sec.push_back(first[cur]);
cur++;
if(i == 4) {
for(int j = 0; j < i-2; j++) {
cout << cols << " ";
sec.push_back(cols);
cur++;
}
cols++;
}
if(i == 6) {
for(int j = 0; j < 2; j++) {
cout << cols << " ";
sec.push_back(cols);
cur++;
}
cols++;
for(int j = 0; j < 2; j++) {
cout << cols << " ";
sec.push_back(cols);
cur++;
}
cols++;
}
cout << first[cur] << " ";
sec.push_back(first[cur]);
cur++;
}
cout << '\n';
cur = 0;
for(int i : v) {
if(i > 2) {
for(int j = 0; j < i; j++) {
cout << sec[cur] << " ";
cur++;
thi.push_back(sec[cur]);
}
} else {
for(int j = 0; j < i; j++) {
cout << cols << " ";
cur++;
thi.push_back(cols);
}
cols++;
}
}
cout << '\n';
cur = 0;
for(int i : v) {
if(i > 2) {
for(int j = 0; j < i; j++) {
cout << first[cur] << " ";
cur++;
}
} else {
for(int j = 0; j < i; j++) {
cout << thi[cur] << " ";
cur++;
}
}
}
cout << '\n';
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
724 KB |
Correct! Azusa and Laika like the garden :) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
724 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Correct |
9 ms |
568 KB |
Correct! Azusa and Laika like the garden :) |
3 |
Correct |
9 ms |
544 KB |
Correct! Azusa and Laika like the garden :) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
724 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Correct |
9 ms |
568 KB |
Correct! Azusa and Laika like the garden :) |
3 |
Correct |
9 ms |
544 KB |
Correct! Azusa and Laika like the garden :) |
4 |
Incorrect |
8 ms |
468 KB |
Expected integer, but "YES" found |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
1 ms |
212 KB |
Incorrect output |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
0 ms |
212 KB |
Incorrect output |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
724 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Correct |
9 ms |
568 KB |
Correct! Azusa and Laika like the garden :) |
3 |
Correct |
9 ms |
544 KB |
Correct! Azusa and Laika like the garden :) |
4 |
Incorrect |
8 ms |
468 KB |
Expected integer, but "YES" found |
5 |
Halted |
0 ms |
0 KB |
- |