Submission #736809

# Submission time Handle Problem Language Result Execution time Memory
736809 2023-05-06T08:54:17 Z flappybird Gardening (RMI21_gardening) C++17
100 / 100
19 ms 924 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 201010
#define MAXS 20
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
#define X 20
bool ispos(int N, int M, int K) {
	if (1ll * N * M > 200000) return false;
	if (N & 1) return false;
	if (M & 1) return false;
	N >>= 1;
	M >>= 1;
	if (N > M) swap(N, M);
	if (K == M + 1 && N == M) return false;
	if (K == N * M - 1) return false;
	return M <= K && K <= N * M;
}
vector<vector<int>> ans;
void solve(int N, int M, int K, int xpos, int ypos) {
	if (!K) return;
	if (M == 1 || N == 1) {
		if (M == 1) { for (int i = 0; i < N; i++) for (auto x : { i * 2, i * 2 + 1 }) for (auto y : { 0, 1 }) ans[xpos + x][ypos + y] = i + 1; }
		else { for (int i = 0; i < M; i++) for (auto x : { 0, 1 }) for (auto y : { 2 * i, 2 * i + 1 }) ans[xpos + x][ypos + y] = i + 1; }
		return;
	}
	if (ispos(N * 2 - 2, M * 2 - 2, K - 1)) {
		int i;
		for (i = 0; i < N * 2; i++) ans[xpos + i][ypos] = ans[xpos + i][ypos + M * 2 - 1] = K;
		for (i = 0; i < M * 2; i++) ans[xpos][ypos + i] = ans[xpos + N * 2 - 1][ypos + i] = K;
		solve(N - 1, M - 1, K - 1, xpos + 1, ypos + 1);
		return;
	}
	if (K >= M && ispos(N * 2 - 2, M * 2, K - M)) {
		for (int i = 0; i < M; i++) for (auto x : { 0, 1 }) for (auto y : { 2 * i, 2 * i + 1 }) ans[xpos + x][ypos + y] = K - i;
		solve(N - 1, M, K - M, xpos + 2, ypos);
		return;
	}
	if (K >= N && ispos(N * 2, M * 2 - 2, K - N)) {
		for (int i = 0; i < N; i++) for (auto x : { i * 2, i * 2 + 1 }) for (auto y : { 0, 1 }) ans[xpos + x][ypos + y] = K - i;
		solve(N, M - 1, K - N, xpos, ypos + 2);
	}
}
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int T;
	cin >> T;
	while (T--) {
		int N, M;
		ll K;
		cin >> N >> M >> K;
		if (!ispos(N, M, K)) {
			cout << "NO" << ln;
			continue;
		}
		ans = vector<vector<int>>(N, vector<int>(M));
		N >>= 1;
		M >>= 1;
		solve(N, M, K, 0, 0);
		cout << "YES" << ln;
		int i, j;
		for (i = 0; i < N * 2; i++) {
			for (j = 0; j < M * 2; j++) cout << ans[i][j] << bb;
			cout << ln;
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 19 ms 852 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Correct 19 ms 852 KB Correct! Azusa and Laika like the garden :)
2 Correct 9 ms 584 KB Correct! Azusa and Laika like the garden :)
3 Correct 11 ms 656 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Correct 19 ms 852 KB Correct! Azusa and Laika like the garden :)
2 Correct 9 ms 584 KB Correct! Azusa and Laika like the garden :)
3 Correct 11 ms 656 KB Correct! Azusa and Laika like the garden :)
4 Correct 11 ms 596 KB Correct! Azusa and Laika like the garden :)
5 Correct 10 ms 648 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Correct 9 ms 704 KB Correct! Azusa and Laika like the garden :)
2 Correct 8 ms 724 KB Correct! Azusa and Laika like the garden :)
3 Correct 12 ms 596 KB Correct! Azusa and Laika like the garden :)
4 Correct 12 ms 708 KB Correct! Azusa and Laika like the garden :)
5 Correct 9 ms 692 KB Correct! Azusa and Laika like the garden :)
6 Correct 9 ms 724 KB Correct! Azusa and Laika like the garden :)
7 Correct 10 ms 672 KB Correct! Azusa and Laika like the garden :)
8 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
9 Correct 9 ms 724 KB Correct! Azusa and Laika like the garden :)
10 Correct 10 ms 728 KB Correct! Azusa and Laika like the garden :)
11 Correct 8 ms 724 KB Correct! Azusa and Laika like the garden :)
12 Correct 9 ms 596 KB Correct! Azusa and Laika like the garden :)
13 Correct 9 ms 596 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Correct 4 ms 452 KB Correct! Azusa and Laika like the garden :)
2 Correct 4 ms 468 KB Correct! Azusa and Laika like the garden :)
3 Correct 4 ms 468 KB Correct! Azusa and Laika like the garden :)
4 Correct 5 ms 448 KB Correct! Azusa and Laika like the garden :)
5 Correct 5 ms 576 KB Correct! Azusa and Laika like the garden :)
6 Correct 3 ms 468 KB Correct! Azusa and Laika like the garden :)
7 Correct 5 ms 468 KB Correct! Azusa and Laika like the garden :)
8 Correct 6 ms 468 KB Correct! Azusa and Laika like the garden :)
9 Correct 5 ms 448 KB Correct! Azusa and Laika like the garden :)
10 Correct 4 ms 468 KB Correct! Azusa and Laika like the garden :)
11 Correct 3 ms 340 KB Correct! Azusa and Laika like the garden :)
12 Correct 4 ms 468 KB Correct! Azusa and Laika like the garden :)
13 Correct 4 ms 468 KB Correct! Azusa and Laika like the garden :)
14 Correct 7 ms 596 KB Correct! Azusa and Laika like the garden :)
15 Correct 3 ms 452 KB Correct! Azusa and Laika like the garden :)
16 Correct 4 ms 440 KB Correct! Azusa and Laika like the garden :)
17 Correct 4 ms 468 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Correct 19 ms 852 KB Correct! Azusa and Laika like the garden :)
2 Correct 9 ms 584 KB Correct! Azusa and Laika like the garden :)
3 Correct 11 ms 656 KB Correct! Azusa and Laika like the garden :)
4 Correct 11 ms 596 KB Correct! Azusa and Laika like the garden :)
5 Correct 10 ms 648 KB Correct! Azusa and Laika like the garden :)
6 Correct 9 ms 704 KB Correct! Azusa and Laika like the garden :)
7 Correct 8 ms 724 KB Correct! Azusa and Laika like the garden :)
8 Correct 12 ms 596 KB Correct! Azusa and Laika like the garden :)
9 Correct 12 ms 708 KB Correct! Azusa and Laika like the garden :)
10 Correct 9 ms 692 KB Correct! Azusa and Laika like the garden :)
11 Correct 9 ms 724 KB Correct! Azusa and Laika like the garden :)
12 Correct 10 ms 672 KB Correct! Azusa and Laika like the garden :)
13 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
14 Correct 9 ms 724 KB Correct! Azusa and Laika like the garden :)
15 Correct 10 ms 728 KB Correct! Azusa and Laika like the garden :)
16 Correct 8 ms 724 KB Correct! Azusa and Laika like the garden :)
17 Correct 9 ms 596 KB Correct! Azusa and Laika like the garden :)
18 Correct 9 ms 596 KB Correct! Azusa and Laika like the garden :)
19 Correct 4 ms 452 KB Correct! Azusa and Laika like the garden :)
20 Correct 4 ms 468 KB Correct! Azusa and Laika like the garden :)
21 Correct 4 ms 468 KB Correct! Azusa and Laika like the garden :)
22 Correct 5 ms 448 KB Correct! Azusa and Laika like the garden :)
23 Correct 5 ms 576 KB Correct! Azusa and Laika like the garden :)
24 Correct 3 ms 468 KB Correct! Azusa and Laika like the garden :)
25 Correct 5 ms 468 KB Correct! Azusa and Laika like the garden :)
26 Correct 6 ms 468 KB Correct! Azusa and Laika like the garden :)
27 Correct 5 ms 448 KB Correct! Azusa and Laika like the garden :)
28 Correct 4 ms 468 KB Correct! Azusa and Laika like the garden :)
29 Correct 3 ms 340 KB Correct! Azusa and Laika like the garden :)
30 Correct 4 ms 468 KB Correct! Azusa and Laika like the garden :)
31 Correct 4 ms 468 KB Correct! Azusa and Laika like the garden :)
32 Correct 7 ms 596 KB Correct! Azusa and Laika like the garden :)
33 Correct 3 ms 452 KB Correct! Azusa and Laika like the garden :)
34 Correct 4 ms 440 KB Correct! Azusa and Laika like the garden :)
35 Correct 4 ms 468 KB Correct! Azusa and Laika like the garden :)
36 Correct 16 ms 880 KB Correct! Azusa and Laika like the garden :)
37 Correct 13 ms 788 KB Correct! Azusa and Laika like the garden :)
38 Correct 13 ms 776 KB Correct! Azusa and Laika like the garden :)
39 Correct 14 ms 844 KB Correct! Azusa and Laika like the garden :)
40 Correct 18 ms 840 KB Correct! Azusa and Laika like the garden :)
41 Correct 13 ms 852 KB Correct! Azusa and Laika like the garden :)
42 Correct 14 ms 904 KB Correct! Azusa and Laika like the garden :)
43 Correct 13 ms 852 KB Correct! Azusa and Laika like the garden :)
44 Correct 13 ms 852 KB Correct! Azusa and Laika like the garden :)
45 Correct 16 ms 852 KB Correct! Azusa and Laika like the garden :)
46 Correct 18 ms 852 KB Correct! Azusa and Laika like the garden :)
47 Correct 15 ms 852 KB Correct! Azusa and Laika like the garden :)
48 Correct 14 ms 852 KB Correct! Azusa and Laika like the garden :)
49 Correct 13 ms 880 KB Correct! Azusa and Laika like the garden :)
50 Correct 13 ms 852 KB Correct! Azusa and Laika like the garden :)
51 Correct 12 ms 760 KB Correct! Azusa and Laika like the garden :)
52 Correct 13 ms 836 KB Correct! Azusa and Laika like the garden :)
53 Correct 14 ms 820 KB Correct! Azusa and Laika like the garden :)
54 Correct 13 ms 852 KB Correct! Azusa and Laika like the garden :)
55 Correct 12 ms 852 KB Correct! Azusa and Laika like the garden :)
56 Correct 14 ms 852 KB Correct! Azusa and Laika like the garden :)
57 Correct 14 ms 900 KB Correct! Azusa and Laika like the garden :)
58 Correct 14 ms 852 KB Correct! Azusa and Laika like the garden :)
59 Correct 14 ms 816 KB Correct! Azusa and Laika like the garden :)
60 Correct 14 ms 924 KB Correct! Azusa and Laika like the garden :)