QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#338128#8217. King's DinnerSGColin#AC ✓1ms3764kbC++172.1kb2024-02-25 18:09:212024-02-25 18:09:22

Judging History

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

  • [2024-02-25 18:09:22]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3764kb
  • [2024-02-25 18:09:21]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

#define pb push_back
#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)

#define N 107

bool s[N][N];

void dfs(int l, int x, int y) {
	if (l <= 5) {
		if (l == 2) s[x][y] = s[x][y + 1] = true; 
		if (l == 3) {
			s[x][y] = s[x][y + 1] = true;
			s[x + 2][y] = s[x + 2][y + 1] = true;
		}
		if (l == 4) {
			s[x][y] = s[x][y + 1] = true;
			s[x][y + 3] = s[x + 1][y + 3] = true;
			s[x + 3][y + 3] = s[x + 3][y + 2] = true;
			s[x + 3][y] = s[x + 2][y] = true;
		}
		if (l == 5) {
			rep(i, 0, 4) rep(j, 0, 4) 
				if (j % 2 == 0 && i % 3 != 2) s[x + i][y + j] = true;
		}
		return;
	}
	if (l % 3 == 0) {
		rep(i, 0, l - 4) if (i % 3 != 2) {
			s[x][y + i] = s[x + 2][y + i] = true;
			s[x + i][y + l - 1] = s[x + i][y + l - 3] = true;
			s[x + l - 1][y + l - 1 - i] = s[x + l - 3][y + l - 1 - i] = true; 
			s[x + l - 1 - i][y] = s[x + l - 1 - i][y + 2] = true;
		}
		dfs(l - 8, x + 4, y + 4); 
	} else if (l % 3 == 1) {
		rep(i, 0, l - 2) if (i % 3 != 2) {
			s[x][y + i] = true;
			s[x + i][y + l - 1] = true;
			s[x + l - 1][y + l - 1 - i] = true; 
			s[x + l - 1 - i][y] = true;
		}
		dfs(l - 4, x + 2, y + 2); 
	} else {
		rep(i, 0, l - 6) if (i % 3 != 2) {
			s[x][y + i] = s[x + 2][y + i] = s[x + 4][y + i] = true;
			s[x + i][y + l - 1] = s[x + i][y + l - 3] = s[x + i][y + l - 5] = true;
			s[x + l - 1][y + l - 1 - i] = s[x + l - 3][y + l - 1 - i] = s[x + l - 5][y + l - 1 - i] = true; 
			s[x + l - 1 - i][y] = s[x + l - 1 - i][y + 2] = s[x + l - 1 - i][y + 4] = true;
		}
		if (l == 8) dfs(2, x + 3, y + 3);
		else dfs(l - 12, x + 6, y + 6);
	}
}

inline void work() {
	int n; cin >> n;
	rep(i, 1, n) rep(j, 1, n) s[i][j] = false;
	dfs(n, 1, 1);
	rep(i, 1, n) {
		rep(j, 1, n) putchar(s[i][j] ? '#' : '.');
		puts("");
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int t; cin >> t;
	while (t--) work();
	return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3740kb

input:

3
1
2
3

output:

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

result:

ok all tests correct (3 test cases)

Test #2:

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

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: 3748kb

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: 0ms
memory: 3764kb

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: 3624kb

input:

1
100

output:

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

result:

ok all tests correct (1 test case)

Extra Test:

score: 0
Extra Test Passed