This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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";
}
}
}
}
int main()
{
//ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int T; cin >> T;
while (T--) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |