QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#445819#8217. King's DinnerposviiAC ✓2ms3976kbC++141.7kb2024-06-16 15:06:162024-06-16 15:06:16

Judging History

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

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

answer

#include<bits/stdc++.h>
using namespace std;
template<typename G> inline void read(G&x) {x=0;G f=1;char ch=getchar();while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();if(ch=='-') f=-1,ch=getchar();while(ch>='0'&&ch<='9') {x=x*10+(ch^48);ch=getchar();}x*=f;}
const int MAXN=100+5;
bool ans[MAXN][MAXN];
void sol(int x,int y) {
	if(x>y) return;
	int n=y-x+1;
	if(n%6==5) {
		for(int i=x;i<=y;i+=2) {
			for(int j=x;j<=y;j+=3) {
				ans[i][j]=ans[i][j+1]=1;
			}
		}return;
	}
	if(n%6==2) {
		for(int i=x;i<=y-3;i+=2) {
			for(int j=x;j<=y;j+=3) {
				ans[i][j]=ans[i][j+1]=1;
			}
		}
		for(int j=x;j<=y;j+=2) {
			ans[n-1][j]=ans[n][j]=1;
		}return;
	}
	if(n==3) {
		ans[x][x]=ans[x][x+1]=ans[y][x]=ans[y][x+1]=1;
		return;
	}
	if(n%3==0) {
		for(int i=0;i<=n-4;i+=3) {
			ans[x][x+i]=ans[x+2][x+i]=ans[x][x+i+1]=ans[x+2][x+i+1]=1;
			ans[x+i][y]=ans[x+i][y-2]=ans[x+i+1][y]=ans[x+i+1][y-2]=1;
			ans[y][y-i]=ans[y-2][y-i]=ans[y][y-i-1]=ans[y-2][y-i-1]=1;
			ans[y-i][x]=ans[y-i][x+2]=ans[y-i-1][x]=ans[y-i-1][x+2]=1;
		}
		sol(x+4,y-4);
	}
	if(n%3==1) {
		for(int i=0;i<=n-4;i+=3) {
			ans[x][x+i]=ans[x][x+i+1]=1;
			ans[x+i][y]=ans[x+i+1][y]=1;
			ans[y][y-i]=ans[y][y-i-1]=1;
			ans[y-i][x]=ans[y-i-1][x]=1;
		}
		sol(x+2,y-2);
	}
}
int T,n;
signed main() {
	#ifndef ONLINE_JUDGE
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
	#endif
	double st=clock();
	read(T);
	while(T--) {
		read(n);
		memset(ans,0,sizeof(ans));
		sol(1,n);
		for(int i=1;i<=n;++i) {
			for(int j=1;j<=n;++j) {
				if(ans[i][j]) putchar('#');
				else putchar('.');
			}putchar('\n');
		}
	}
	double ed=clock();
	cerr<<(ed-st)/CLOCKS_PER_SEC;
	return 0; 
}

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

详细

Test #1:

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

input:

3
1
2
3

output:

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

result:

ok all tests correct (3 test cases)

Test #2:

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

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

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

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

input:

1
100

output:

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

result:

ok all tests correct (1 test case)

Extra Test:

score: 0
Extra Test Passed