QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#530470#8217. King's DinnerMax_FWLAC ✓4ms3696kbC++141.9kb2024-08-24 16:22:042024-08-24 16:22:07

Judging History

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

  • [2024-08-24 16:22:07]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:3696kb
  • [2024-08-24 16:22:04]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 110;
int T, n;
char mp[N][N];

void SOLVE(int x, int xx, int y, int yy){
	if (x > xx)
		return;
	
	for (int i = x; i <= xx - 3; i += 2)
		mp[i][y] = mp[i][y + 1] = '#';
	for (int i = y; i <= yy - 3; i += 2)
		mp[xx][i] = mp[xx - 1][i] = '#';
	
	for (int i = xx; i >= x + 3; i -= 2)
		mp[i][yy] = mp[i][yy - 1] = '#';
	for (int i = yy; i >= y + 3; i -= 2)
		mp[x][i] = mp[x + 1][i] = '#';
	
	SOLVE(x + 3, xx - 3, y + 3, yy - 3);
}

void Solve(){
	cin >> n;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			mp[i][j] = '.';
	
	if (n == 4){
		cout << "##.#" << endl;
		cout << "...#" << endl;
		cout << "#..." << endl;
		cout << "#.##" << endl;
		return;
	}else if (n & 1){
		for (int i = 1; i <= n; i += 2)
			for (int j = 1; j + 1 <= n; j += 3)
				mp[i][j] = mp[i][j + 1] = '#';
		
		if (!(n % 3)){
			for (int i = 1; i <= n; i++)
				for (int j = n - 2; j <= n; j++)
					mp[i][j] = '.';
			
			for (int i = 1; i + 1 <= n; i += 3)
				mp[i][n - 2] = mp[i][n] = mp[i + 1][n - 2] = mp[i + 1][n] = '#';
		}else if (n % 3 == 1){
			for (int i = 1; i + 1 <= n; i += 3)
				mp[i][n] = mp[i + 1][n] = '#';
		}
	}else if (!(n % 6))
		SOLVE(1, n, 1, n);
	else{
		for (int i = 1; i <= n - 3; i += 2)
			for (int j = 1; j + 1 <= n; j += 3)
				mp[i][j] = mp[i][j + 1] = '#';
		
		for (int i = 1; i <= n; i += 2)
			mp[n][i] = mp[n - 1][i] = '#';
		
		if (n % 3 == 1){
			for (int i = 1; i + 1 <= n - 2; i += 3)
				mp[i][n] = mp[i + 1][n] = '#';
			
			mp[n - 1][n - 1] = '.';
			mp[n][n - 1] = mp[n][n] = '#';
		}
	}
	
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++)
			cout << mp[i][j] ;
		cout << endl;
	}
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    cin >> T;
    
    while (T--)
    	Solve();
	
    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
3

output:

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

result:

ok all tests correct (3 test cases)

Test #2:

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

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: 4ms
memory: 3628kb

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: 2ms
memory: 3684kb

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

input:

1
100

output:

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

result:

ok all tests correct (1 test case)

Extra Test:

score: 0
Extra Test Passed