QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#736418#9621. 连方CarucaoAC ✓13ms4680kbC++201.5kb2024-11-12 10:55:062024-11-12 10:55:07

Judging History

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

  • [2024-11-12 10:55:07]
  • 评测
  • 测评结果:AC
  • 用时:13ms
  • 内存:4680kb
  • [2024-11-12 10:55:06]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int N=1e5+10;
char c[8][N];
string a,b;
int n;
void out()
{
	cout<<"Yes"<<endl;
	for(int i=1;i<=7;++i)
	{
		for(int j=1;j<=n;++j)
		  cout<<c[i][j];
		cout<<endl;
	}
}
void work()
{
    cin>>n;
    cin>>a>>b;
    a=" "+a;
    b=" "+b;
    for(int i=1;i<=7;++i)
      for(int j=0;j<=n+1;++j)
    	c[i][j]='.';
    int u=0,v=0;
    for(int i=1;i<=n;++i) u+=(a[i]=='.');
    for(int i=1;i<=n;++i) v+=(b[i]=='.');
    if(u==0&&v==0)
    {
    	for(int i=1;i<=7;++i)
    	  for(int j=1;j<=n;++j)
    	    c[i][j]='#';
    	out();
    	return;
	}
	if(u==0||v==0)
	{
		cout<<"No"<<endl;
		return;
	}
    for(int i=1;i<=n;++i) c[1][i]=a[i];
    for(int i=1;i<=n;++i)
    {
    	if(a[i]=='#') c[2][i]='.';
    	else c[2][i]='#';
	}
	int l=0,r=n+1;
	for(int i=1;i<=n;++i)
	  if(c[2][i]=='.'&&(c[2][i-1]=='#'||c[2][i+1]=='#'))
	  {
	  	  l=i;
	  	  break;
	  }
	c[3][l]='#';
	for(int i=1;i<=n;++i)
    {
    	if(b[i]=='#') c[6][i]='.';
    	else c[6][i]='#';
	}
	for(int i=n;i;--i)
	  if(c[6][i]=='.'&&(c[6][i-1]=='#'||c[6][i+1]=='#'))
	  {
	  	  r=i;
	  	  break;
	  }
	c[5][r]='#';
	if(abs(l-r)<=1)
	{
		if(l) c[4][l]='#';
		else c[4][r]='#';
	}
	else
	{
		int minn=min(l,r)+1,maxn=max(l,r)-1;
		for(int i=minn;i<=maxn;++i) c[4][i]='#';
	}
    for(int i=1;i<=n;++i) c[7][i]=b[i];
    out();
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T=1;
    cin>>T;
    for(;T;--T)
      work();
    return 0;
}

详细

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 13ms
memory: 3728kb

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: 13ms
memory: 3608kb

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 12ms
memory: 3716kb

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: 8ms
memory: 3768kb

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 10ms
memory: 4452kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 7ms
memory: 4680kb

input:

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

output:

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

result:

ok Correct.