QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#739719#9621. 连方xly_tyty#AC ✓7ms4740kbC++231.6kb2024-11-12 22:48:402024-11-12 22:48:40

Judging History

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

  • [2024-11-12 22:48:40]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:4740kb
  • [2024-11-12 22:48:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N=1e6+10,mod=998244353;
string ans[7];

void solve() {
	int n; cin >> n;
	string a, b;
	cin >> a >> b;
	
	for (int i = 1; i <= 5; i ++ ) {
		ans[i].clear();
		ans[i] = a;
	}
	
	if (a == b&&a==string(n,'#')) {
		cout<<"Yes"<<'\n';
		for (int i = 0; i < 7; i ++) {
			cout << a << '\n';
		}
		return ;
	}
	
	if (a == string(n, '#') || b == string(n, '#') ) {
		cout << "No" << '\n';
		return ;
	}
	cout << "Yes\n";
	for (int i = 0; i < n; i ++ ) {
		if ( a[i] == '#' ) {
			ans[1][i] = '.';
		} else {
			ans[1][i] = '#';
		}
	}
	for (int i = 0; i < n; i ++ ) {
		if ( b[i] == '#' ) {
			ans[5][i] = '.';
		} else {
			ans[5][i] = '#';
		}
	}
	
	int id1 = 0;
	int id2 = 0;
	ans[2] = string(n, '.');
	for(int i = 0; i < n; i ++ ) {
		if ( ans[1][i] == '.' && ((i+1<n&&ans[1][i + 1] == '#')||(i-1>=0&&ans[1][i-1]=='#'))) {
			ans[2][i] = '#';
			id1 = i;
			break ;
		}
	}
	ans[4] = string(n, '.');
	for(int i = 0; i < n; i ++ ){
		if ( ans[5][i] == '.' && ((i+1<n&&ans[5][i + 1] == '#')||(i-1>=0&&ans[5][i-1]=='#')) ) {
			ans[4][i] = '#';
			id2 = i;
			break ;
		}
	}
	ans[3] = string(n, '.');
	if(id1>id2)swap(id1,id2);
	if(id2-id1<=1)
	{
		ans[3][id2]='#';
	}
	for (int i = id1+1; i < id2; i ++ ) {
		ans[3][i] = '#';
	}
	ans[0] = a;
	ans[6] = b;
	for ( int i = 0; i < 7; i ++) {
		cout << ans[i] << '\n';
	}
	// cout << '\n';
	return ;
}
int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int t= 1;
	cin >> t ;
	while(t -- ) {
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.