QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#758323#9621. 连方suyueovoAC ✓7ms4072kbC++231.3kb2024-11-17 17:45:122024-11-17 17:45:13

Judging History

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

  • [2024-11-17 17:45:13]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:4072kb
  • [2024-11-17 17:45:12]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long


void solve(){
	int n;
	cin >> n;
	vector<string> a(7);
	cin >> a[0] >> a[6];
	bool f0 = false, f6 = false;
	for(char c : a[0])
		f0 |= (c == '.');
	for(char c : a[6])
		f6 |= (c == '.');
	if(f0 != f6) {
		cout << "No\n";
		return;
	}
	cout << "Yes\n";
	if(f0 == false) {
		for(int i = 0; i < 7; i ++) cout << a[0] << "\n";
		return;
	}
	for(int i = 1; i < 6; i ++) a[i] = string(n, '.');
	for(int i = 0; i < n; i ++)	if(a[0][i] == '.') a[1][i] = '#';
	for(int i = 0; i < n; i ++)	if(a[6][i] == '.') a[5][i] = '#';
	int l = -1, r = -1;
	for(int i = 0; i < n and l == -1; i ++) {
		if(a[1][i] == '#') continue;
		if(i - 1 >= 0 and a[1][i - 1] == '#') l = i;
		if(i + 1 < n  and a[1][i + 1] == '#') l = i;
	}

	for(int i = 0; i < n and r == -1; i ++) {
		if(a[5][i] == '#') continue;
		if(i - 1 >= 0 and a[5][i - 1] == '#') r = i;
		if(i + 1 <  n and a[5][i + 1] == '#') r = i;
	}
	a[2][l] = a[4][r] = '#';
	if(l > r) swap(l, r);
	if(l == r or l + 1 == r ){
		a[3][l] = '#';
	} else {
		for(int i = l + 1; i < r ; i ++) a[3][i] = '#';
	}
	for(int i = 0; i < 7; i ++)
		cout << a[i] << "\n";
	return;	 
}

signed main() {
	ios::sync_with_stdio(false), cin.tie(nullptr);
	
	int T;
	cin >> T;
	while(T --)
		solve();

	return 0;
}	

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 4ms
memory: 4072kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 4ms
memory: 3936kb

input:

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

output:

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

result:

ok Correct.