QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#736744#9621. 连方fsy_juruoAC ✓14ms9856kbC++173.8kb2024-11-12 13:07:362024-11-12 13:07:36

Judging History

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

  • [2024-11-12 13:07:36]
  • 评测
  • 测评结果:AC
  • 用时:14ms
  • 内存:9856kb
  • [2024-11-12 13:07:36]
  • 提交

answer

#include <bits/stdc++.h>
using LL = long long;

const int maxN = 1e6 + 10;
int T, n;
char A[7][maxN];

std::vector<std::pair<int, int> > seg;
int main() {
	std::ios::sync_with_stdio(false); std::cin.tie(nullptr);
	std::cin >> T;
	while(T--) {
		std::cin >> n;

		for(int i = 0; i < 7; i++) {
			for(int j = 0; j < n; j++) A[i][j] = '.';
		}

		std::cin >> A[0] >> A[6];

		bool isFullA = true, isFullB = true;

		for(int j = 0; j < n; j++) isFullA &= (A[0][j] == '#');
		for(int j = 0; j < n; j++) isFullB &= (A[6][j] == '#');

		if(isFullA && isFullB) {
			std::cout << "Yes\n";
			for(int i = 0; i < 7; i++) {
				for(int j = 0; j < n; j++) {
					std::cout << "#";
				}
				std::cout << "\n";
			}
			continue;
		} else if(isFullA || isFullB) {
			std::cout << "No\n";
			continue;
		}

		for(int j = 0; j < n; j++) A[1][j] = (A[0][j] == '.' ? '#' : '.');
		for(int j = 0; j < n; j++) A[5][j] = (A[6][j] == '.' ? '#' : '.');

		int posA = -1;
		for(int j = 1; j < n; j++) {
			if(posA == -1 && A[1][j] == '.' && A[1][j - 1] == '#') {
				posA = j;
			}
		}
		for(int j = 0; j < n - 1; j++) {
			if(posA == -1 && A[1][j] == '.' && A[1][j + 1] == '#') {
				posA = j;
			}
		}

		int posB = -1;
		for(int j = 1; j < n; j++) {
			if(posB == -1 && A[5][j] == '.' && A[5][j - 1] == '#') {
				posB = j;
			}
		}
		for(int j = 0; j < n - 1; j++) {
			if(posB == -1 && A[5][j] == '.' && A[5][j + 1] == '#') {
				posB = j;
			}
		}

		A[2][posA] = A[4][posB] = '#';

		if(posA == posB) {
			A[3][posA] = '#';
		} else {
			if(posA <= posB) std::swap(posA, posB);
			if(posA - posB == 1) A[3][posA] = '#';
			else {
				for(int i = posB + 1; i < posA; i++) {
					A[3][i] = '#';
				}
			}
		}

		std::cout << "Yes\n";
		for(int i = 0; i < 7; i++) {
			for(int j = 0; j < n; j++) {
				std::cout << A[i][j];
			}
			std::cout << "\n";
		}
		// int lft = -1, rgt = -1;
		// for(int i = 0; i < n; i++) {
		// 	if((A[0][i] == '#' || A[6][i] == '#')) {
		// 		if(lft == -1) lft = i, rgt = i;
		// 		else ++rgt;
		// 	} else {
		// 		if(lft != -1) seg.emplace_back(std::make_pair(lft, rgt));
		// 		lft = -1, rgt = -1;
		// 	}
		// }	
		// if(lft != -1) seg.emplace_back(std::make_pair(lft, rgt));

		// for(auto S : seg) {
		// 	int l = S.first, r = S.second;

		// 	for(int i = l; i <= r; i++) {
		// 		A[1][i] = (A[0][i] == '.' ? '#' : '.');
		// 		A[5][i] = (A[6][i] == '.' ? '#' : '.');
		// 	}

		// 	int pos = -1;
		// 	for(int i = l; i <= r; i++) {
		// 		if(A[1][i] == '#') {
		// 			pos = i;
		// 			break;
		// 		}
		// 	}

		// 	if(A[5][pos] == '#') {
		// 		A[2][pos] = A[3][pos] = A[4][pos] = '#';
		// 	} else {
		// 		int pos2 = 0;
		// 		for(int i = pos + 1; i <= r; i++) {
		// 			if(A[5][i] == '#') {
		// 				pos2 = i; break;
		// 			}
		// 		}

		// 		if(pos2) {
		// 			for(int i = 2; i <= 4; i++) {
		// 				for(int j = pos; j < pos2; j++) {
		// 					A[i][j] = '#';
		// 				}
		// 			}

		// 			if(pos2 != pos + 1) A[2][pos] = A[3][pos] = A[4][pos] = '.';
		// 		} else {
		// 			for(int i = pos - 1; i >= l; i--) {
		// 				if(A[5][i] == '#') {
		// 					pos2 = i; break;
		// 				}
		// 			}
		// 			if(pos2) {
		// 				for(int i = 2; i <= 4; i++) {
		// 					for(int j = pos2 + 1; j <= pos; j++) {
		// 						A[i][j] = '#';
		// 					}
		// 				}

		// 				if(pos2 != pos - 1) A[2][pos] = A[3][pos] = A[4][pos] = '.';
		// 			}
		// 		}
		// 	}
		// }

		// // for(int i = 1; i < n - 1; i++) {
		// // 	if(A[0][i] == A[6][i] && A[0][i] == '.') {
		// // 		for()
		// // 	} 
		// // }
		// std::cout << "Yes\n";

		// for(int i = 0; i < 7; i++) {
		// 	for(int j = 0; j < n; j++) {
		// 		std::cout << A[i][j] << "\0\n"[j == n - 1];
		// 	}
		// }
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 9856kb

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 10ms
memory: 7716kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 14ms
memory: 9808kb

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

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.