QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#738685#9621. 连方MOQEE#AC ✓17ms4576kbC++202.0kb2024-11-12 19:42:432024-11-12 19:42:46

Judging History

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

  • [2024-11-12 19:42:46]
  • 评测
  • 测评结果:AC
  • 用时:17ms
  • 内存:4576kb
  • [2024-11-12 19:42:43]
  • 提交

answer

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("O2")
using namespace std;
#define int long long
#define ll long long
#define llu unsigned long long
#define endl "\n"

typedef pair<int, int> PII;

int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
const long long inf = 1LL << 60;
const int mod = 998244353;
const int N = 1e6 + 7;

void solve()
{
	int n;
	cin >> n;
	string a, b;
	cin >> a >> b;
	if (a.find(".") == -1 && b.find(".") == -1) {
		cout << "Yes" << endl;
		for (int i = 1; i <= 7; i ++ ) {
			for (int j = 1; j <= n; j ++ ) cout << "#";
			cout << endl;
		}
		return ;
	}
	if ((a.find(".") == -1) != (b.find(".") == -1)) {
		cout << "No" << endl;
		return ;
	}
	cout << "Yes" << endl;
	a = "#" + a + "#";
	b = "#" + b + "#";
	vector<string> v(10);
	v[1] = a, v[7] = b;
	for (int i = 2; i < 7; i ++ ) {
		for (int j = 0; j <= n + 1; j ++ ) {
			v[i] += '.';
		}
	}
	for (int i = 1; i <= n; i ++ ) {
		if (v[1][i] == '.') v[2][i] = '#';
		if (v[7][i] == '.') v[6][i] = '#';
	}
	int st1 = 0;
	int st2 = 0;
	for (int i = 1; i <= n; i ++ ) {
		if (a[i] == '#' && a[i - 1] == '.') {
			st1 = i;
			break;
		}
		if (a[i] == '#' && a[i + 1] == '.') {
			st1 = i;
			break;
		}
	}
	for (int i = 1; i <= n; i ++ ) {
		if (b[i] == '#' && b[i - 1] == '.') {
			st2 = i;
			break;
		}
		if (b[i] == '#' && b[i + 1] == '.') {
			st2 = i;
			break;
		}
	}
	v[3][st1] = '#';
	v[5][st2] = '#';
	if (st1 == st2) v[4][st1] = '#';
	else if (abs(st1 - st2) == 1) v[4][st2] = '#';
	else {
		if (st1 > st2) swap(st1, st2);
		for (int i = st1 + 1; i < st2; i ++ ) {
			v[4][i] = '#';
		}
	}
	for (int i = 1; i <= 7; i ++ ) {
		for (int j = 1; j <= n; j ++ ) {
			cout << v[i][j];
		}
		cout << endl;
	}
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	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: 0ms
memory: 3500kb

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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: 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: 17ms
memory: 3760kb

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: 17ms
memory: 3944kb

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

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 15ms
memory: 4576kb

input:

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

output:

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

result:

ok Correct.