QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#443941#8217. King's Dinner_l_l_AC ✓1ms3840kbC++142.3kb2024-06-15 16:53:152024-06-15 16:53:15

Judging History

你现在查看的是最新测评结果

  • [2024-06-15 16:53:15]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3840kb
  • [2024-06-15 16:53:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
char str[MAXN][MAXN];
void draw(int dx, int dy, int n) {
	if (n < 2) return;
	if (n == 2) return str[dx][dy] = str[dx][dy + 1] = '#', void();
	if (n == 3) return str[dx][dy] = str[dx][dy + 1] = str[dx + 2][dy] = str[dx + 2][dy + 1] = '#', void();
	if (n % 2 == 0) {
		for (int i = 1; i < n / 2; i++) {
			str[dx][dy + 2 * i - 2] = str[dx + 1][dy + 2 * i - 2] = '#';
			str[dx + 2 * i + 1][dy] = str[dx + 2 * i + 1][dy + 1] = '#';
			str[dx + n - 1][dy + 2 * i + 1] = str[dx + n - 2][dy + 2 * i + 1] = '#';
			str[dx + 2 * i - 2][dy + n - 1] = str[dx + 2 * i - 2][dy + n - 2] = '#';
		}
		draw(dx + 3, dy + 3, n - 6);
	}
	else if (n % 6 == 1) {
		for (int i = 1; i <= n / 3; i++) {
			str[dx][dy + 3 * i - 3] = str[dx][dy + 3 * i - 2] = '#';
			str[dx + 3 * i - 1][dy] = str[dx + 3 * i][dy] = '#';
			str[dx + 3 * i - 3][dy + n - 1] = str[dx + 3 * i - 2][dy + n - 1] = '#';
			str[dx + n - 1][dy + 3 * i - 1] = str[dx + n - 1][dy + 3 * i] = '#';
		}
		draw(dx + 2, dy + 2, n - 4);
	}
	else if (n % 6 == 5) {
		for (int i = 1; i <= n / 2 + 1; i++) for (int j = 1; j <= n / 3 + 1; j++) {
			str[dx + i * 2 - 2][dy + j * 3 - 3] = str[dx + i * 2 - 2][dy + j * 3 - 2] = '#';
		}
	}
	else {
		// for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) str[dx + i - 1][dy + j - 1] = '?';
		// draw(dx, dy, n / 2);
		// draw(dx + n / 2 + 1, dy, n / 2);
		// draw(dx, dy + n / 2 + 1, n / 2);
		// draw(dx + n / 2 + 1, dy + n / 2 + 1, n / 2);
		for (int i = 1; i <= (n + 1) / 2; i++) for (int j = 1; j < n / 3; j++) {
			str[dx + 2 * i - 2][dy + 3 * j - 3] = str[dx + 2 * i - 2][dy + 3 * j - 2] = '#';
		}
		for (int i = 1; i <= n / 3; i++) {
			str[dx + 3 * i - 3][dy + n - 1] = str[dx + 3 * i - 2][dy + n - 1] = '#';
			str[dx + 3 * i - 3][dy + n - 3] = str[dx + 3 * i - 2][dy + n - 3] = '#';
		}
	}
}
int main() {
	int t; scanf("%d", &t); while (t--) {
		int n; scanf("%d", &n);
		for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) str[i][j] = '.';
		for (int i = 1; i <= n; i++) str[i][n + 1] = 0;
		draw(1, 1, n);
		for (int i = 1; i <= n; i++) puts(str[i] + 1);
	}
}
/*
#.##.##.#
#.......#
...#.#...
##.#.#.##
.........
##.#.#.##
...#.#...
#.......#
#.##.##.#

##.##.#.#
......#.#
##.##....
......#.#
##.##.#.#
.........
##.##....
......#.#
##.##.#.#
*/

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3828kb

input:

3
1
2
3

output:

.
##
..
##.
...
##.

result:

ok all tests correct (3 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3704kb

input:

50
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

output:

.
##
..
##.
...
##.
#.##
#...
...#
##.#
##.##
.....
##.##
.....
##.##
#.#.##
#.#...
....##
##....
...#.#
##.#.#
##.##.#
......#
#.##...
#.....#
..##..#
#......
#.##.##
#.#.#.##
#.#.#...
......##
##.##...
......##
##......
...#.#.#
##.#.#.#
##.##.#.#
......#.#
##.##....
......#.#
##.##.#.#
.........
...

result:

ok all tests correct (50 test cases)

Test #3:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

39
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

output:

##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#.#
................................................#.#
##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##....
................................................#.#
##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#.#
...........................................

result:

ok all tests correct (39 test cases)

Test #4:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

11
90
91
92
93
94
95
96
97
98
99
100

output:

#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.##
#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...
........................................................................................##
##.#.#.#.#.#.#.#.#.#.#.#.#....

result:

ok all tests correct (11 test cases)

Test #5:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

1
100

output:

#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.##
#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...
.....................................................................................................

result:

ok all tests correct (1 test case)

Extra Test:

score: 0
Extra Test Passed