QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#737219#9621. 连方ucup-team059#AC ✓7ms4264kbC++201.7kb2024-11-12 15:06:192024-11-12 15:06:19

Judging History

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

  • [2024-11-12 15:06:19]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:4264kb
  • [2024-11-12 15:06:19]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long

void solve(){
	int n;
	std::string a, b;
	std::cin >> n >> a >> b;

	if (a == std::string(n, '#') && b == std::string(n, '#')){
		std::cout << "Yes\n";
		for (int i = 0; i < 7; i++){
			std::cout << std::string(n, '#') << '\n';
		}
		return;
	}
	if (a == std::string(n, '#') || b == std::string(n, '#')){
		std::cout << "No\n";
		return;
	}

	std::cout << "Yes\n";

	std::vector<std::string> ans(7, std::string(n, '.'));
	ans[0] = a, ans[6] = b;

	for (int i = 0; i < n; i++){
		if (a[i] == '#') {
			ans[1][i] = '.';
		}else{
			ans[1][i] = '#';
		}
		if (b[i] == '#') {
			ans[5][i] = '.';
		}else{
			ans[5][i] = '#';
		}
	}

	int posa = -1, posb = -1;

	for (int i = 0; i < n && posa == -1; i++){
		if (ans[1][i] == '.'){
			if (i && ans[1][i - 1] == '#'){
				posa = i;
			}
			if (i < n - 1 && ans[1][i + 1] == '#'){
				posa = i;
			}
		}
	}
	for (int i = 0; i < n && posb == -1; i++){
		if (ans[5][i] == '.'){
			if (i && ans[5][i - 1] == '#'){
				posb = i;
			}
			if (i < n - 1 && ans[5][i + 1] == '#'){
				posb = i;
			}
		}
	}
	assert(!(posa == -1 && posb == -1));
	if (posa == -1 || posb == -1){
		std::cout << "No\n";
		return;
	}

	ans[2][posa] = '#';
	ans[4][posb] = '#';
	if (posa > posb){
		std::swap(posa, posb);
	}
	if (posb - posa <= 1){
		ans[3][posa] = '#';
	}else{
		for (int i = posa + 1; i < posb; i++){
			ans[3][i] = '#';
		}
	}
	assert(ans[0] == a && ans[6] == b);
	for (int i = 0; i < 7; i++){
		std::cout << ans[i] << '\n';
	}

}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	int t;

	std::cin >> t;

	while (t--){
		solve();
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 0ms
memory: 4264kb

input:

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

output:

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

result:

ok Correct.