#include <iostream>
#include <vector>
using namespace std;
void solve()
{
int N, M, K; cin >> N >> M >> K;
if (N == 1) {
cout << "NO\n";
return;
}
else if (N == 2) {
if (2 * K == M) {
cout << "YES\n";
for (int tt = 0; tt < 2; tt++) {
for (int i = 0; i < M; i++) {
cout << (i / 2 + 1) << ' ';
}
cout << '\n';
}
return;
}
else {
cout << "NO\n";
return;
}
}
else if (N == 3) {
cout << "NO\n";
return;
}
else if (N == 4) {
if (M % 2 || K == M - 1) {
cout << "NO\n";
return;
}
else {
if (M / 2 <= K && K <= M) {
cout << "YES\n";
vector<vector<int>> ans(4, vector<int>(M));
//2K-M+1 2K-M+2 ... M에서 총 2M-2K개. (i-(2K-M+1))/2 + 2K- M + 1
//K - M/2 까지
for (int i = 0; i < 2 * K - M; i++) {
ans[0][i] = ans[1][i] = i / 2 + 1;
ans[2][i] = ans[3][i] = i / 2 + K - M / 2 + 1;
}
if (K != M) {
for (int i = 2 * K - M; i < M; i++) ans[0][i] = ans[3][i] = 2 * K - M + 1;
ans[1][2*K-M] = ans[2][2*K-M] = ans[1][M-1] = ans[2][M-1] = 2 * K - M + 1;
//2*K-M+2~K까지 총 M - K - 1개 만들기
for (int i = 0; i < M - K - 1; i++) {
int color = i + 2 * K - M + 2;
ans[1][2*K-M+1+2*i] = ans[2][2*K-M+1+2*i] = ans[1][2*K-M+2+2*i] = ans[2][2*K-M+2+2*i] = color;
}
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < M; j++) {
cout << ans[i][j] << ' ';
}
cout << '\n';
}
}
else {
cout << "NO\n";
}
}
}
else cout << "NO\n";
}
int main()
{
//ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int T; cin >> T;
while (T--) {
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
712 KB |
Correct! Azusa and Laika like the garden :) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
712 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Correct |
15 ms |
612 KB |
Correct! Azusa and Laika like the garden :) |
3 |
Correct |
15 ms |
504 KB |
Correct! Azusa and Laika like the garden :) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
712 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Correct |
15 ms |
612 KB |
Correct! Azusa and Laika like the garden :) |
3 |
Correct |
15 ms |
504 KB |
Correct! Azusa and Laika like the garden :) |
4 |
Failed |
11 ms |
468 KB |
Incorrect output |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Failed |
1 ms |
212 KB |
Incorrect output |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Failed |
1 ms |
212 KB |
Incorrect output |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
712 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Correct |
15 ms |
612 KB |
Correct! Azusa and Laika like the garden :) |
3 |
Correct |
15 ms |
504 KB |
Correct! Azusa and Laika like the garden :) |
4 |
Failed |
11 ms |
468 KB |
Incorrect output |
5 |
Halted |
0 ms |
0 KB |
- |