Submission #869275

# Submission time Handle Problem Language Result Execution time Memory
869275 2023-11-03T23:39:09 Z MinaRagy06 Gardening (RMI21_gardening) C++17
11 / 100
12 ms 856 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;
		if (x < 0) {
			cout << "NO\n";
			continue;
		}
		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 Correct 12 ms 856 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Correct 12 ms 856 KB Correct! Azusa and Laika like the garden :)
2 Correct 7 ms 604 KB Correct! Azusa and Laika like the garden :)
3 Correct 9 ms 604 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Correct 12 ms 856 KB Correct! Azusa and Laika like the garden :)
2 Correct 7 ms 604 KB Correct! Azusa and Laika like the garden :)
3 Correct 9 ms 604 KB Correct! Azusa and Laika like the garden :)
4 Failed 6 ms 604 KB Output contains values not between 1 and k
5 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 348 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 856 KB Correct! Azusa and Laika like the garden :)
2 Correct 7 ms 604 KB Correct! Azusa and Laika like the garden :)
3 Correct 9 ms 604 KB Correct! Azusa and Laika like the garden :)
4 Failed 6 ms 604 KB Output contains values not between 1 and k
5 Halted 0 ms 0 KB -