제출 #1347196

#제출 시각아이디문제언어결과실행 시간메모리
1347196MunkhErdeneGardening (RMI21_gardening)C++17
11 / 100
7 ms836 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define _ << " " <<
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ull unsigned long long
#define lll __int128
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define BlueCrowner ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
const ll mod = 1e9 + 7;
const ll mod1 = 998244353;
const ll naim = 1e9;
const ll max_bit = 60;
const ull tom = ULLONG_MAX;
const ll MAXN = 100005;
const ll LOG = 20;
const ll NAIM = 1e18;
const ll N = 2e6 + 5;
// ---------- GCD ----------
ll gcd(ll a, ll b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}
// ---------- LCM ----------
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
// ---------- Modular Exponentiation ----------
ll modpow(ll a, ll b, ll m = mod) {
	ll c = 1;
	a %= m;
	while (b > 0) {
		if (b & 1) c = c * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return c;
}
// ---------- Modular Inverse (Fermat’s Little Theorem) ----------
ll modinv(ll a, ll m = mod) {
	return modpow(a, m - 2, m);
}
// ---------- Factorials and Inverse Factorials ----------
ll fact[N], invfact[N];
void pre_fact(ll n = N-1, ll m = mod) {
	fact[0] = 1;
	for (ll i = 1; i <= n; i++) fact[i] = fact[i-1] * i % m;
	invfact[n] = modinv(fact[n], m);
	for (ll i = n; i > 0; i--) invfact[i-1] = invfact[i] * i % m;
}
// ---------- nCr ----------
ll nCr(ll n, ll r, ll m = mod) {
	if (r < 0 || r > n) return 0;
	return fact[n] * invfact[r] % m * invfact[n-r] % m;
}
// ---------- Sieve of Eratosthenes ----------
vector<ll> primes;
bool is_prime[N];
void sieve(ll n = N-1) {
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (ll i = 2; i * i <= n; i++) {
		if (is_prime[i]) {
			for (ll j = i * i; j <= n; j += i)
				is_prime[j] = false;
		}
	}
	for (ll i = 2; i <= n; i++)
		if (is_prime[i]) primes.pb(i);
}
void solve() {
	ll n, m, k; cin >> n >> m >> k;
	if(n & 1 || m & 1) {
		no;
		return;
	}
	if((n / 2) * (m / 2) < k) {
		no;
		return;
	}
	vector<vector<ll>> ans(n, vector<ll>(m));
	if(n == 2) {
		if(k != m / 2) {
			no;
			return;
		}
		yes;
		for(ll i = 0; i < m; i ++) {
			ans[0][i] = ans[1][i] = i / 2 + 1;
		}
		FOR(i, 0, n) {
			FOR(j, 0, m) cout << ans[i][j] << ' '; cout << '\n';
		}
		return;
	}
	if(n == 4) {
		if(k < (m / 2) || k > m || k == m - 1) {
			no;
			return;
		}
		yes;
		ll y = m - k;
		if(m - k) {
			ans[1][0] = ans[2][0] = ans[1][2 * y - 1] = ans[2][2 * y - 1] = 1;
		}
		ll cnt = (y > 0) + 1;
		FOR(i, 0, 2 * y) ans[0][i] = ans[3][i] = 1;
		for(ll i = 1; i < 2 * y - 1; i += 2) {
			ans[1][i] = ans[1][i + 1] = ans[2][i] = ans[2][i + 1] = cnt++;
		}
		for(ll i = 2 * y; i < m; i += 2) {
			ans[0][i] = ans[1][i] = ans[0][i + 1] = ans[1][i + 1] = cnt++;
			ans[2][i] = ans[3][i] = ans[2][i + 1] = ans[3][i + 1] = cnt++;
		}
		FOR(i, 0, n) {
			FOR(j, 0, m) cout << ans[i][j] << ' '; cout << '\n';
		}
		return;

	}
}
int main() {
	BlueCrowner;
	ll t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...