QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#769266#9621. 连方YFffffffAC ✓14ms6336kbC++231.8kb2024-11-21 16:51:382024-11-21 16:51:39

Judging History

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

  • [2024-11-21 16:51:39]
  • 评测
  • 测评结果:AC
  • 用时:14ms
  • 内存:6336kb
  • [2024-11-21 16:51:38]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 10, INF = 1e18, MOD = 1e9 + 7;
typedef pair<int, int> PII;
typedef unsigned long long ull;
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
int arr[N], brr[N];
map<int,int> mp;
map<PII,int> mpp;
vector<PII> vi, g[N];
vector<int> ans;
bool st[N];
int n, m, k;
void print(string s){
	for(int i = 1; i <= n; i ++) cout << s[i];
	cout << "\n";
}
void solve()
{
	cin >> n;
	string t1, t2, t3, t4, t5, t6, t7;
	cin >> t1 >> t7;
	if(((int)t1.find('.') != -1) ^ ((int)t7.find('.') != -1)){
		cout << "NO\n";
		return;
	}else if(((int)t1.find('.') == -1) && ((int)t7.find('.') == -1)){
		cout << "YES\n";
		for(int i = 0; i < 7; i ++) cout << t1 << "\n";
		return;
	}
	for(int i = 0; i <= n + 1; i ++){
		if(i == 0 || i == n + 1) t2 += " ";
		else t2 += '.';
	}
	t3 = t4 = t5 = t6 = t2;
	
	for(int i = 0; i < n; i ++){
		if(t1[i] == '.') t2[i + 1] = '#';
		if(t7[i] == '.') t6[i + 1] = '#';
	}
	int l = 0, r = 0;
	for(int i = 1; i <= n; i ++){
		if(t2[i] == '#'){
			if(t2[i - 1] =='.'){
				t3[i - 1] = '#';
				l = i - 1;
				break;
			}else if(t2[i + 1] == '.'){
				t3[i + 1] = '#';
				l = i + 1;
				break;
			}
		}
	}
	for(int i = 1; i <= n; i ++){
		if(t6[i] == '#'){
			if(t6[i - 1] =='.'){
				t5[i - 1] = '#';
				r = i - 1;
				break;
			}else if(t6[i + 1] == '.'){
				t5[i + 1] = '#';
				r = i + 1;
				break;
			}
		}
	}
	if(l > r) swap(l, r);
	for(int i = l + 1; i < r; i ++){
		t4[i] = '#';
	}
	if(r - l <= 1) t4[l] = '#';
	cout << "YES\n"<< t1 << "\n";
	print(t2);
	print(t3);
	print(t4);
	print(t5);
	print(t6);
	cout << t7 << "\n";
}

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T = 1;
	cin >> T;
	while (T --)	solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

YES
#..#
.##.
#...
#...
.#..
#..#
.##.
YES
##.#.
..#.#
.#...
.#...
.#...
#.#..
.#.##
NO
YES
.######.######.####.#.#####
#......#......#....#.#.....
.#.........................
.#.........................
.#.........................
#....###....##.#######.....
.####...####..#.......#####
YES
########...

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 13ms
memory: 5748kb

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

input:

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

output:

YES
#######.#######.#########################
.......#.......#.........................
......#..................................
.......########..........................
...............#.........................
................#...#.......#............
################.###.#######.############
YE...

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 13ms
memory: 5644kb

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

input:

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

output:

NO
YES
###...
...###
..#...
.#....
.#....
..##.#
##..#.
YES
.#.######
#.#......
.#.......
#........
#........
.#.##....
#.#..####
YES
######.##########################################
......#..........................................
.....#...........................................
......#............

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 12ms
memory: 6304kb

input:

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

output:

YES
###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....

result:

ok Correct.

Test #7:

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

input:

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

output:

YES
##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........

result:

ok Correct.