QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#739408#9621. 连方I_be_wannaAC ✓6ms2264kbC++142.0kb2024-11-12 21:41:122024-11-12 21:41:12

Judging History

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

  • [2024-11-12 21:41:12]
  • 评测
  • 测评结果:AC
  • 用时:6ms
  • 内存:2264kb
  • [2024-11-12 21:41:12]
  • 提交

answer

#include<cstdio>
#include<utility>
#define _MAXN 100010
int n,T,L[2]={1,7};
char s[8][_MAXN];
inline char rev(char x) {return '#'+'.'-x;}
bool check()
{
	bool f[2]={1};
	for (int h:{0,1})
		for (int i=1;i<=n;i++)
			if (!(f[h]=(s[L[h]][i]=='#'))) break;
	if (f[0]^f[1]) std::printf("No\n");
		else std::printf("Yes\n");
	if (f[0]&&f[1])
		for (int i=1;i<=7;i++) std::printf("%s\n",s[1]+1);
	return !(f[0]||f[1]);
}
void init()
{
	for (int i=2;i<=6;i++)
	{
		for (int j=1;j<=n;j++) s[i][j]='.';
		s[i][n+1]='\0';
	}
	return;
}
int process(int a,int b,int c)
{
	for (int i=1;i<=n;i++)
		s[b][i]=rev(s[a][i]);
	int xx=0;
	for (int i=1;i<n;i++)
	{
		if (s[b][i]=='#' && s[b][i+1]=='.') {s[c][xx=i+1]='#';break;}
		if (s[b][i]=='.' && s[b][i+1]=='#') {s[c][xx=i]='#';break;}
	}
	return xx;
}
void processmid(int x,int y)
{
	if (x>y) std::swap(x,y);
	if (y<=x+1) s[4][x]='#';
	else for(int i=x+1;i<y;i++) s[4][i]='#';
	return;
}
int main()
{
	std::scanf("%d",&T);
	while (T--)
	{
		std::scanf("%d%s%s",&n,1[s]+1,7[s]+1);
		if (!check()) continue;
		init();
		processmid(process(1,2,3),process(7,6,5));
		for (int i=1;i<=7;i++) std::printf("%s\n",s[i]+1);
	}
	return 0; 
}
/*#include<cstdio>
#include<utility>
#define _MAXN 100010
int n,T,L[2]={1,7};
char s[8][_MAXN];
inline char rev(char x) {return '#'+'.'-x;}
bool check()
{
	bool f[2]={1};
	for (int h:{0,1})
		for (int i=1;i<=n;i++)
			if (!(f[h]=(s[L[h]][i]=='#'))) break;
	if (f[0]^f[1]) std::printf("No\n");
		else std::printf("Yes\n");
	if (f[0]&&f[1])
		for (int i=1;i<=7;i++) std::printf("%s\n",s[1]+1);
	return !(f[0]||f[1]);
}
void init()
{
	for (int i=2;i<=6;i++)
	{
		for (int j=1;j<=n;j++) s[i][j]='.';
		s[i][n+1]='\0';
	}
	return;
}
int process(int a,int b,int c)
{
	for (int i=1;i<=n;i++)
		s[b][i]=rev(s[a][i]);
	int xx=0;
	for (int i=1;i<n;i++)
	{
		if (s[b][i]=='#' && s[b][i+1]=='.') {s[c][xx=i+1]='#';break;}
		if (s[b][i]=='.' && s[b][i+1]=='#') {s[c][xx=i]='#';break;}
	}
	return 0; 
}*/

詳細信息

Test #1:

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

input:

5
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
10
##########
##########

output:

Yes
#..#
.##.
#...
#...
.#..
#..#
.##.
Yes
##.#.
..#.#
.#...
.#...
.#...
#.#..
.#.##
No
Yes
.######.######.####.#.#####
#......#......#....#.#.....
.#.........................
.#.........................
.#.........................
#....###....##.#######.....
.####...####..#.......#####
Yes
########...

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 6ms
memory: 1640kb

input:

10000
6
.#..##
..#...
5
#..#.
##...
6
.###.#
...###
17
.####..#######..#
###########.#####
6
..##.#
#.##.#
25
#.##.##############.####.
####################.##.#
9
##.#..##.
##..#####
6
.###.#
##.###
6
###..#
#.####
25
#####################.#.#
######.##################
6
.#.###
.##..#
6
..####
#......

output:

Yes
.#..##
#.##..
.#....
.#....
..#...
##.###
..#...
Yes
#..#.
.##.#
#....
#....
.#...
..###
##...
Yes
.###.#
#...#.
.#....
..#...
...#..
###...
...###
Yes
.####..#######..#
#....##.......##.
.#...............
..########.......
..........#......
...........#.....
###########.#####
Yes
..##.#
##..#.
...

result:

ok Correct.

Test #3:

score: 0
Accepted
time: 3ms
memory: 1596kb

input:

10000
41
#######.#######.#########################
################.###.#######.############
6
..#..#
#..##.
6
#.#...
#...#.
6
.#.##.
....##
6
...#.#
##..#.
33
#####.###########################
###########.#####################
6
.##.##
.##.#.
5
..##.
####.
17
#.###.##########.
####.##.#####.##.
5
....

output:

Yes
#######.#######.#########################
.......#.......#.........................
......#..................................
.......########..........................
...............#.........................
................#...#.......#............
################.###.#######.############
Ye...

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 3ms
memory: 1644kb

input:

10000
6
..####
.#....
6
...#.#
#..##.
9
..####.##
######..#
33
#######################.#####..##
######.######.###########.#######
6
####.#
#..##.
6
...###
##.###
25
######.#.#.##############
.#########.##########.###
17
############.####
###############.#
6
#..#.#
#####.
6
.#.###
..#...
49
########...

output:

Yes
..####
##....
..#...
.#....
.#....
#.####
.#....
Yes
...#.#
###.#.
...#..
.##...
#.....
.##..#
#..##.
Yes
..####.##
##....#..
..#......
...##....
.....#...
......##.
######..#
Yes
#######################.#####..##
.......................#.....##..
......................#..........
......########...

result:

ok Correct.

Test #5:

score: 0
Accepted
time: 3ms
memory: 1612kb

input:

10000
5
...#.
#####
6
###...
##..#.
9
.#.######
#.#..####
49
######.##########################################
########.#############.##########################
41
###########.#######.#####################
##############.##########################
6
###..#
###.##
49
#################################...

output:

No
Yes
###...
...###
..#...
.#....
.#....
..##.#
##..#.
Yes
.#.######
#.#......
.#.......
#........
#........
.#.##....
#.#..####
Yes
######.##########################################
......#..........................................
.....#...........................................
......#............

result:

ok Correct.

Test #6:

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

input:

2
100000
###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...

output:

Yes
###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 2ms
memory: 2264kb

input:

2
100000
##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...

output:

Yes
##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........

result:

ok Correct.