Submission #869274

# Submission time Handle Problem Language Result Execution time Memory
869274 2023-11-03T23:37:20 Z MinaRagy06 Gardening (RMI21_gardening) C++17
0 / 100
13 ms 860 KB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
 
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int t;
	cin >> t;
	while (t--) {
		int n, m, k;
		cin >> n >> m >> k;
		if (n % 2 || m % 2 || k > n * m / 4) {
			cout << "NO\n";
			continue;
		}
		int a[n][m];
		if (n == 2) {
			if (k != m / 2) {
				cout << "NO\n";
				continue;
			}
			cout << "YES\n";
			for (int j = 0; j < m; j += 2) {
				a[0][j] = a[1][j] = a[0][j + 1] = a[1][j + 1] = k;
				k--;
			}
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					cout << a[i][j] << ' ';
				}
				cout << '\n';
			}
			continue;
		}
		int x = 2 * k - m;
		for (int j = 0; j < x; j += 2) {
			a[0][j] = k;
			a[1][j] = k;
			a[0][j + 1] = k;
			a[1][j + 1] = k;
			k--;
			a[2][j] = k;
			a[3][j] = k;
			a[2][j + 1] = k;
			a[3][j + 1] = k;
			k--;
		}
		int rem = m - x;
		if (rem) {
			if (rem < 4) {
				cout << "NO\n";
				continue;
			}
			for (int j = x + 1; j < m - 1; j += 2) {
				a[1][j] = a[2][j] = a[1][j + 1] = a[2][j + 1] = k;
				k--;
			}
			if (k > 1) {
				cout << "NO\n";
				continue;
			}
			for (int i = 0; i < 4; i++) {
				a[i][x] = a[i][m - 1] = k;
			}
			for (int j = x + 1; j < m - 1; j++) {
				a[0][j] = a[3][j] = k;
			}
		}
		cout << "YES\n";
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				cout << a[i][j] << ' ';
			}
			cout << '\n';
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Failed 13 ms 860 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 13 ms 860 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 13 ms 860 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 348 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 344 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 13 ms 860 KB Incorrect output
2 Halted 0 ms 0 KB -