QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#759081#9621. 连方woodie_0064#AC ✓12ms4592kbC++201.8kb2024-11-17 21:31:022024-11-17 21:31:02

Judging History

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

  • [2024-11-17 21:31:02]
  • 评测
  • 测评结果:AC
  • 用时:12ms
  • 内存:4592kb
  • [2024-11-17 21:31:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
char a[8][maxn];
void ans() {
	cout << "Yes\n";
	for(int i = 1; i <= 7; i++) {
		for(int j = 1; j <= n; j++) {
			cout << a[i][j];
		}
		cout << '\n';
	}
}
void work(){
	cin >> n;
	string s, t;
	cin >> s >> t;
	int x = 0, y = 0;
	for(int i = 1; i <= n; i++) {
		a[1][i] = s[i - 1];
		x += (s[i - 1] == '#');
	}
	for(int i = 1; i <= n; i++) {
		a[7][i] = t[i - 1];
		y += (t[i - 1] == '#');
	}
	for(int i = 2; i <= 6; i++) {
		for(int j = 1; j <= n; j++) {
			a[i][j] = '.';
		}
	}
	if(x == 0 || y == 0) {
		ans();
		return;
	}
	if(x == n && y == n) {
		cout << "Yes\n";
		for(int i = 1; i <= 7; i++) {
			for(int j = 1; j <= n; j++) {
				cout << '#';
			}
			cout << '\n';
		}
		return;
	}
	if(x == n || y == n) {
		cout << "No\n";
		return;
	}
	for(int i = 1; i <= n; i++) {
		a[2][i] = (s[i - 1] == '#' ? '.' : '#');
		a[6][i] = (t[i - 1] == '#' ? '.' : '#');
	}
	int p = 0, q = 0;
	for(int i = 1; i <= n; i++) {
		if(a[2][i] == '#' && i + 1 <= n && a[2][i + 1] == '.') {
			p = i + 1;
			break;
		}
		if(a[2][i] == '#' && i - 1 >= 1 && a[2][i - 1] == '.') {
			p = i - 1;
			break;
		}
	}
	for(int i = 1; i <= n; i++) {
		if(a[6][i] == '#' && i + 1 <= n && a[6][i + 1] == '.') {
			q = i + 1;
			break;
		}
		if(a[6][i] == '#' && i - 1 >= 1 && a[6][i - 1] == '.') {
			q = i - 1;
			break;
		}
	}
	a[3][p] = a[5][q] = '#';
	if(p == q) {
		a[4][p] = '#';
	}
	else if(abs(p - q) == 1) {
		a[4][p] = '#';
	}
	else {
		for(int i = min(p, q) + 1; i < max(p, q); i++) {
			a[4][i] = '#';
		}
	}
	ans();
}


int main(){
//	freopen("test.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T;
	cin >> T;
	while(T--){
		work();
	}	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 8ms
memory: 3724kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 8ms
memory: 3736kb

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

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 11ms
memory: 4544kb

input:

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

output:

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

result:

ok Correct.