#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[6][200009];
int n, m;
int cnt = 0;
void fill1(int r0, int c0, int rows, int cols){
cnt++;
for(int i=0; i<rows; i++)
for(int j=0; j<cols; j++)
a[r0+i][c0+j] = cnt;
}
void printanswer(){
printf("YES\n");
for(int i=0; i<n; i++){
for(int j=0; j<m; j++)
printf("%d ", a[i][j]);
printf("\n");
}
}
int main(){
ll k;
int t;
scanf("%d", &t);
while(t--){
scanf("%d %d %lld", &n, &m, &k);
cnt = 0;
if(n%2 || m%2)
printf("NO\n");
else if(n==2){
if(k == m/2){
for(int i=0; i<m; i+=2)
fill1(0, i, 2, 2);
printanswer();
}
else
printf("NO\n");
}
else{
if(m/2 <= k && k <= m && k != m-1){
for(int i=0; i<2*k-m; i+=2){
fill1(0, i, 2, 2);
fill1(2, i, 2, 2);
}
fill1(0, 2*k-m, 4, 2*(m-k));
for(int i=2*k-m+1; i<m-1; i+=2){
fill1(1, i, 2, 2);
}
printanswer();
}
else
printf("NO\n");
}
}
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
24 | scanf("%d", &t);
| ~~~~~^~~~~~~~~~
Main.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | scanf("%d %d %lld", &n, &m, &k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
2908 KB |
Correct! Azusa and Laika like the garden :) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
2908 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Correct |
8 ms |
604 KB |
Correct! Azusa and Laika like the garden :) |
3 |
Correct |
8 ms |
604 KB |
Correct! Azusa and Laika like the garden :) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
2908 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Correct |
8 ms |
604 KB |
Correct! Azusa and Laika like the garden :) |
3 |
Correct |
8 ms |
604 KB |
Correct! Azusa and Laika like the garden :) |
4 |
Failed |
6 ms |
2648 KB |
Output contains values not between 1 and k |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
2908 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Correct |
8 ms |
604 KB |
Correct! Azusa and Laika like the garden :) |
3 |
Correct |
8 ms |
604 KB |
Correct! Azusa and Laika like the garden :) |
4 |
Failed |
6 ms |
2648 KB |
Output contains values not between 1 and k |
5 |
Halted |
0 ms |
0 KB |
- |