QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#791795#9621. 连方fuchenAC ✓41ms4400kbC++111.3kb2024-11-28 20:58:372024-11-28 20:58:38

Judging History

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

  • [2024-11-28 20:58:38]
  • 评测
  • 测评结果:AC
  • 用时:41ms
  • 内存:4400kb
  • [2024-11-28 20:58:37]
  • 提交

answer

#include <bits/stdc++.h>
#define  ll long long
#define  db double
using namespace std;
const int N=100010;
char a[10][N];
void slove(){
	int n;
	cin >>n;
	cin >> a[0] >> a[6];
	int cnt1=0,cnt2=0;
	for(int i=1;i<=5;i++){
		for(int j=0;j<n;j++){
			a[i][j]='.';
		}
	}
	for(int i=0;i<n;i++){
		if(a[0][i]=='#'){
			cnt1++;
			a[1][i]='.';
		}else{
			a[1][i]='#';
		}
		if(a[6][i]=='#'){
			cnt2++;
			a[5][i]='.';
		}else{
			a[5][i]='#';
		}
	}
	if((cnt1==n && cnt2!=n) || (cnt1!=n &&cnt2==n)){
		cout << "No" << endl;
		return;
	}
	cout << "Yes" << endl;
	if(cnt1==n && cnt2==n){
		for(int i=0;i<7;i++){
			cout << a[0] << endl;
		}
		return ;
	}
	int l=0,r=0;
	for(int i=0;i<n;i++){
		if(a[1][i]=='#') continue;
		if(i-1>=0 && a[1][i-1]=='#') l=i;
		if(i+1<n && a[1][i+1]=='#') l=i;
	}
	for(int i=0;i<n;i++){
		if(a[5][i]=='#') continue;
		if(i-1>=0 && a[5][i-1]=='#') r=i;
		if(i+1<n && a[5][i+1]=='#') r=i;
	}
	a[2][l]=a[4][r]='#';
	if(l>r) swap(l,r);
	if(l==r || l+1==r){
		a[3][l]='#';
	}else{
		for(int i=l+1;i<=r-1;i++){
			a[3][i]='#';
		}
	}
	for(int i=0;i<7;i++){
		for(int j=0;j<n;j++){
			cout << a[i][j];
		}
		cout << endl;
	} 
}
int main()
{	
	std::ios::sync_with_stdio(false);
	int T;
	cin >>T;
	while(T--){
		slove();
	}
	return 0;	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 19ms
memory: 3760kb

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: 15ms
memory: 3700kb

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 41ms
memory: 3632kb

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: 15ms
memory: 3780kb

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.