QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#766191#9621. 连方tsaiAC ✓37ms7548kbC++142.0kb2024-11-20 16:31:222024-11-20 16:31:25

Judging History

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

  • [2024-11-20 16:31:25]
  • 评测
  • 测评结果:AC
  • 用时:37ms
  • 内存:7548kb
  • [2024-11-20 16:31:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int x[10][100005]={0};
void solve(){
	int n;
	scanf("%d",&n);
	string a;
	string b;
	cin>>a>>b;
	int jd1=0,jd11=0;
	int jd2=0,jd22=0;
	int st1=0,st2=0;
	for(int i=1;i<=7;i++){
		for(int j=1;j<=n;j++){
			x[i][j]=0;
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]=='.'){
			jd1=1;
			if(st1==0&&i>0)st1=i+1;
			x[1][i+1]=0;	
		}else{
			jd11=1;
			x[1][i+1]=1;	
		}
	}
	for(int i=0;i<n;i++){
		if(b[i]=='.'){
			jd2=1;
			if(st2==0&&i>0)st2=i+1;
			x[7][i+1]=0;	
		}else{
			jd22=1;
			x[7][i+1]=1;
		}
	}
	if(jd1==1&&jd11==1&&jd2==0){
		printf("No\n");
		return ;
	}
	if(jd1==0&&jd22==1&&jd2==1){
		printf("No\n");
		return ;
	}
	printf("Yes\n");
	if(jd11==0&&jd2==0){
		cout<<a<<"\n";
		for(int i=2;i<=7;i++){
			for(int j=1;j<=n;j++){
				printf("#");
			}
			printf("\n");
		}
		return ;
	}
	if(jd1==0&&jd22==0){
		for(int i=1;i<=6;i++){
			for(int j=1;j<=n;j++){
				printf("#");
			}
			printf("\n");
		}
		cout<<b<<"\n";
		return ;
	}
	if(jd1==0&&jd2==0){
		for(int i=1;i<=7;i++){
			for(int j=1;j<=n;j++){
				printf("#");
			}
			printf("\n");
		}
		return ;
	}
	for(int i=2;i<=n;i++){
		if(a[i-1]=='.'){
			x[2][i]=1;
		}
	}
	for(int i=2;i<st1;i++){
		x[3][i]=1;
	}
	if(st1==2){
		x[3][1]=1;
	}else if(st1<=1){
		x[3][1]=1;x[2][1]=1;
	}
	if(st2==2){
		x[5][1]=1;
	}else if(st2<=1){
		x[6][1]=1;x[5][1]=1;		
	}
	x[4][1]=1;
	for(int i=2;i<=n;i++){
		if(b[i-1]=='.'){
			x[6][i]=1;
		}
	}
	for(int i=2;i<st2;i++){
		x[5][i]=1;
	}
	cout<<a<<"\n";
	for(int i=2;i<=6;i++){
		for(int j=1;j<=n;j++){
			if(x[i][j]==1){
				printf("#");
			}else{
				printf(".");
			}
		}
		printf("\n");
	}
	cout<<b<<"\n";
	return ;
}
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		solve();
	}
	return 0;
}
/*
110
2
##
..
2
..
##
27
.######.######.####.#.#####
.####...####..#.......#####
6
######
.####.
3
#..
..#
2
#.
.#
2
.#
.#
2
#.
#.
2
.#
#.
1
#
#
1
.
.
1
#
.
1
.
#
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 32ms
memory: 5904kb

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: 37ms
memory: 5956kb

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 30ms
memory: 6148kb

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: 33ms
memory: 5892kb

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 25ms
memory: 7376kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 23ms
memory: 7548kb

input:

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

output:

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

result:

ok Correct.