QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#470491#8217. King's DinnerPhantomThreshold#AC ✓2ms3724kbC++171.8kb2024-07-10 14:16:182024-07-10 14:16:19

Judging History

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

  • [2024-07-10 14:16:19]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3724kb
  • [2024-07-10 14:16:18]
  • 提交

answer

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

char ans[150][150];

void solve(int n){
	if (n==2){
		return;
	}
	else if (n==3){
		ans[1][1]='#';
		ans[2][1]='#';
		return;
	}
	else if (n==4){
		ans[1][1]='#';ans[1][3]='#';
		ans[2][1]='#';ans[2][3]='#';
		return;
	}
	else if (n==5){
		ans[1][1]='#';ans[1][2]='#';			ans[1][4]='#';
												ans[2][4]='#';
		ans[3][1]='#';
		ans[4][1]='#';				ans[4][3]='#';ans[4][4]='#';
		return;
	}
	else if (n==6){
		for (int i=1;i<=5;i++) if (i!=3){
			for (int j=1;j<=5;j+=2) ans[i][j]='#';	
		}
	}
	else if (n==7){
		ans[1][1]='#';ans[1][3]='#';ans[1][5]='#';ans[1][6]='#';
		ans[2][1]='#';ans[2][3]='#';
		ans[3][5]='#';ans[3][6]='#';
		ans[4][1]='#';ans[4][2]='#';
		ans[5][4]='#';ans[5][6]='#';
		ans[6][1]='#';ans[6][2]='#';ans[6][4]='#';ans[6][6]='#';
	}
	else{
		if (n%2==0){
			for (int i=n-5;i<=n-1;i++) if (i!=n-3){
				for (int j=1;j<=n;j+=2){
					ans[i][j]='#';
				}
			}
			for (int i=1;i<=n-6;i+=2){
				for (int j=n-5;j<=n-1;j++) if (j!=n-3){
					ans[i][j]='#';	
				}
			}
		}
		else{
			for (int i=n-5;i<=n-1;i++) if (i!=n-3){
				for (int j=n-5;j<=n;j+=2){
					ans[i][j]='#';
				}
			}
			for (int i=n-5;i<=n-1;i+=2){
				ans[i][1]=ans[i][2]='#';
				ans[1][i]=ans[2][i]='#';	
			}
			for (int i=n-5;i<=n-1;i++) if (i!=n-3){
				for (int j=4;j<=n-6;j+=2){
					ans[i][j]=ans[j][i]='#';
				}
			}
		}
		solve(n-6);
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	int Tcase=1;
	cin >> Tcase;
	for (;Tcase--;){
		int n;
		cin >> n;
		if (n==1){
			cout << "." << "\n";
			continue;	
		}
		for (int i=1;i<=n+1;i++)
			for (int j=1;j<=n+1;j++) ans[i][j]='.';
		solve(n+1);
		for (int i=1;i<=n;i++){
			for (int j=1;j<=n;j++){
				cout << ans[i][j];
			}
			cout << "\n";
		}
	}
	return 0;	
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
3

output:

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

result:

ok all tests correct (3 test cases)

Test #2:

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

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

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

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

input:

1
100

output:

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

result:

ok all tests correct (1 test case)

Extra Test:

score: 0
Extra Test Passed