QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#781840#9621. 连方_Strelitzia#AC ✓39ms4352kbC++231.9kb2024-11-25 17:40:372024-11-25 17:40:48

Judging History

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

  • [2024-11-25 17:40:48]
  • 评测
  • 测评结果:AC
  • 用时:39ms
  • 内存:4352kb
  • [2024-11-25 17:40:37]
  • 提交

answer

#include <bits/stdc++.h>
#define lowbit(x) (x & -x)
#define int long long
#define lc (p << 1)
#define rc (p << 1 | 1)
using namespace std;
typedef pair<int, int> PII;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e5 + 5, M = 1e6 + 5, INF = 0x3f3f3f3f, mod = 998244353;

int T = 1, n;
char s[10][N];

void work(int l, int r, int i, int j) {
	for (int k = l; k <= r; k++) {
		if (s[i][k] == '.') s[j][k] = '#';
		else s[j][k] = '.';
	}
}

void init() {
	for (int i = 2; i <= 6; i++)
		for (int j = 1; j <= n; j++) s[i][j] = '.';
}


void solve() {
	
	cin >> n; init();
	
	for (int i = 1; i <= n; i++) cin >> s[1][i];
	for (int i = 1; i <= n; i++) cin >> s[7][i];
	
	bool ok1 = true, ok2 =true;
	for (int i = 1; i <= n; i++) {
		if (s[1][i] == '.') ok1 = false;
		if (s[7][i] == '.') ok2 = false;
	}
	
	if (ok1 != ok2) {
		cout << "No" << endl;
		return ;
	} else if (ok1) {
		cout << "Yes" << endl;
		for (int i = 1; i <= 7; i++) {
			for (int j = 1; j <= n; j++) cout << s[1][j];
			cout << endl;
		}
		return ;
	}
	
	cout << "Yes" << endl;
	
	work(1, n, 1, 2);
	work(1, n, 7, 6);
	
	int l = -1, r = -1;
	for (int i = 1; i <= n && l == -1; i++) {
		if (s[2][i] == '#') continue;
		if (i > 1 && s[2][i - 1] == '#') l = i;
		if (i < n && s[2][i + 1] == '#') l = i;
	}
	
	for (int i = 1; i <= n && r == -1; i++) {
		if (s[6][i] == '#') continue;
		if (i > 1 && s[6][i - 1] == '#') r = i;
		if (i < n && s[6][i + 1] == '#') r = i;
	}
	
	s[3][l] = s[5][r] = '#';
	if (l > r) swap(l, r);
	
	if (r - l <= 1) s[4][l] = '#';
	else {
		for (int i = l + 1; i < r; i++)
			s[4][i] = '#';
	}
	
	for (int i = 1; i <= 7; i++) {
		for (int j = 1; j <= n; j++) cout << s[i][j];
		cout << endl;
	}
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> T;
	while (T--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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: 39ms
memory: 3792kb

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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: 39ms
memory: 3732kb

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 9ms
memory: 4352kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 6ms
memory: 4292kb

input:

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

output:

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

result:

ok Correct.