QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#745318#9621. 连方yhdddAC ✓38ms4740kbC++142.1kb2024-11-14 09:07:472024-11-14 09:07:53

Judging History

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

  • [2024-11-14 09:07:53]
  • 评测
  • 测评结果:AC
  • 用时:38ms
  • 内存:4740kb
  • [2024-11-14 09:07:47]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define mod 998244353ll
#define pii pair<int,int>
#define fi first
#define se second
#define mems(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define db double
using namespace std;
const int maxn=200010;
const int inf=1e18;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
	return x*f;
}
bool Mbe;

int n;
char s[maxn],t[maxn];
char c[8][maxn];
void work(){
	n=read();scanf("%s%s",s+1,t+1);
	for(int i=1;i<=n;i++)c[1][i]=s[i];
	for(int i=1;i<=n;i++)c[7][i]=t[i];
	for(int i=2;i<=6;i++){
		for(int j=0;j<=n+1;j++)c[i][j]='.';
	}
	bool fl=0;for(int i=1;i<=n;i++)if(s[i]=='#')fl=1;
	if(!fl){
		puts("Yes");
		for(int i=1;i<=n;i++)if(t[i]=='.')c[6][i]='#';
		for(int i=1;i<=7;i++){
			for(int j=1;j<=n;j++)printf("%c",c[i][j]);puts("");
		}
		return ;
	}
	fl=0;for(int i=1;i<=n;i++)if(t[i]=='#')fl=1;
	if(!fl){
		puts("Yes");
		for(int i=1;i<=n;i++)if(s[i]=='.')c[2][i]='#';
		for(int i=1;i<=7;i++){
			for(int j=1;j<=n;j++)printf("%c",c[i][j]);puts("");
		}
		return ;
	}
	for(int i=1;i<=n;i++)if(s[i]=='.')c[2][i]='#';
	for(int i=1;i<=n;i++)if(t[i]=='.')c[6][i]='#';
	int p1=0,p2=0;
	for(int i=1;i<=n;i++)if(c[2][i]=='.'&&(c[2][i-1]=='#'||c[2][i+1]=='#'))p1=i;
	for(int i=1;i<=n;i++)if(c[6][i]=='.'&&(c[6][i-1]=='#'||c[6][i+1]=='#'))p2=i;
	if(!p1&&!p2){
		puts("Yes");
		for(int i=1;i<=7;i++){
			for(int j=1;j<=n;j++)printf("#");puts("");
		}
		return ;
	}
	if(!p1||!p2){puts("No");return ;}
	puts("Yes");
	c[3][p1]=c[5][p2]='#';
	if(abs(p1-p2)<=1)c[4][p1]='#';
	else{
		for(int i=min(p1,p2)+1;i<max(p1,p2);i++)c[4][i]='#';
	}
	for(int i=1;i<=7;i++){
		for(int j=1;j<=n;j++)printf("%c",c[i][j]);puts("");
	}
}

// \
444

bool Med;
int T;
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	
//	ios::sync_with_stdio(0);
//	cin.tie(0);cout.tie(0);
	
//	cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
	
	T=read();
	while(T--)work();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 38ms
memory: 4672kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 34ms
memory: 4740kb

input:

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

output:

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

result:

ok Correct.