QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#752191#9621. 连方Cai_Guang#AC ✓30ms12388kbC++232.8kb2024-11-15 22:46:342024-11-15 22:46:34

Judging History

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

  • [2024-11-15 22:46:34]
  • 评测
  • 测评结果:AC
  • 用时:30ms
  • 内存:12388kb
  • [2024-11-15 22:46:34]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long
#ifndef Cai_Guang
#define debug //
#define test //
#endif

void solve(int T, int tc) {
	int n;
	std::cin >> n;
	
	std::string s, t;
	std::cin >> s >> t;
	
	
	s = ' ' + s;
	t = ' ' + t;
	
	int cnts = 0, cntt = 0;
	for (int i = 1; i <= n; i++) {
		cnts += s[i] == '#';
	}
	for (int i = 1; i <= n; i++) {
		cntt += t[i] == '#';
	}
	
	if (cnts == n && cntt == n) {
		std::cout << "Yes\n";
		for (int i = 1; i <= 7; i++) {
			std::cout << std::string(n, '#') << '\n';
		}
		return;
	} else if ((cnts == n && cntt != 0) || (cnts != 0 && cntt == n)) {
		std::cout << "No\n";
		return;
	}
	
	std::vector G(10, std::vector<int>(n + 3));
	
	for (int i = 1; i <= n; i++) {
		if (s[i] == '#') {
			G[1][i] = 1;
		} 
		if (t[i] == '#') {
			G[7][i] = 1;
		}
	}

	if (cnts != 0) {
		for (int i = 1; i <= n; i++) {
			if (G[1][i] == 0) {
				G[2][i] = 1;
			}
		}
	}
	if (cntt != 0) {
		for (int i = 1; i <= n; i++) {
			if (G[7][i] == 0) {
				G[6][i] = 1;
			}
		}
	}
	if (cnts == 0 || cntt == 0) {
		std::cout << "Yes\n";
		for (int i = 1; i <= 7; i++) {
			for (int j = 1; j <= n; j++) {
				std::cout << (G[i][j] ? "#" : ".");
			} std::cout << '\n';
		}
		return;
	}
	
	std::vector<int> v;
	
	for (int i = 1; i <= n; i++) {
		if (G[2][i] == 1) {
			int l = i - 1, r = i;
			for (int j = i; j <= n + 1; j++) {
				if (!G[2][j]) {
					r = j;
					break;
				}
			}
			if (l != 0)
				G[3][l] = 1, v.push_back(l);
			else if (r != n + 1)
				G[3][r] = 1, v.push_back(r);
			break;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (G[6][i] == 1) {
			int l = i - 1, r = i;
			for (int j = i; j <= n + 1; j++) {
				if (!G[6][j]) {
					r = j;
					break;
				}
			}
			if (l != 0)
				G[5][l] = 1, v.push_back(l);
			else if (r != n + 1)
				G[5][r] = 1, v.push_back(r);
			break;
		}
	}
	
	for (int i = 1; i <= n; i++) {
		if (G[3][i] && G[5][i]) {
			G[4][i] = 1;
			goto G;
		}
	}
	
	for (int i = 1; i <= n; i++) {
		if (G[3][i + 1] && G[5][i]) {
			G[4][i] = 1;
			goto G;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (G[3][i - 1] && G[5][i]) {
			G[4][i] = 1;
			goto G;
		}
	}
	
	std::sort(v.begin(), v.end());
	
	for (int i = v[0] + 1; i <= v[1] - 1; i++) {
		G[4][i] = 1;
	}
	
	G:;
	
	std::cout << "Yes\n";
	for (int i = 1; i <= 7; i++) {
		for (int j = 1; j <= n; j++) {
			std::cout << (G[i][j] ? "#" : ".");
		} std::cout << '\n';
	}
	// cout << '\n';
	
	
}

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

#ifdef Cai_Guang
//freopen("1.in", "r", stdin);
localTest = true;
#endif
   
	int t = 1;
	std::cin >> t;
	for (int i = 1; i <= t; i++) {
	    solve(t, i);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 29ms
memory: 3932kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 29ms
memory: 4016kb

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

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 27ms
memory: 12292kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 23ms
memory: 12388kb

input:

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

output:

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

result:

ok Correct.