QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#736381#9621. 连方Qiu_yiAC ✓13ms4688kbC++201.5kb2024-11-12 10:36:442024-11-12 10:36:44

Judging History

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

  • [2024-11-12 10:36:44]
  • 评测
  • 测评结果:AC
  • 用时:13ms
  • 内存:4688kb
  • [2024-11-12 10:36:44]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
const int N = 100010;

char s[10][N];

int n;
string a,b;

void solve(){
	
	cin >> n;
	cin >> a >> b;
	a = ' ' + a,b = ' ' + b;
	int ca = 0,cb = 0;
	
	for(int i=1;i<=7;i++)
		for(int j=1;j<=n+1;j++)
			s[i][j] = '.';
	
	for(int i=1;i<=n;i++) if(a[i] == '#') ca++;
	for(int i=1;i<=n;i++) if(b[i] == '#') cb++;
	
	if(ca == n and cb == n){
		cout << "Yes" << endl;
		for(int i=1;i<=7;i++){
			for(int j=1;j<=n;j++){
				cout << '#';
			}
			cout << endl;
		}
		return ;
	}		
	
	if(ca == n or cb == n){
		cout << "No" << endl;
		return ;
	}
	
	for(int i=1;i<=n;i++){
		s[1][i] = a[i];
		s[2][i] = a[i] == '#' ? '.' : '#';
		s[6][i] = b[i] == '#' ? '.' : '#';
		s[7][i] = b[i];
	}
	
	int l,r;
	
	for(int i=1;i<=n;i++){
		if(s[2][i] == '.'){
			if(s[2][i-1] == '#' or s[2][i+1] == '#'){
				s[3][i] = '#';
				l = i;
				break;
			}
		}
	}
	
	for(int i=1;i<=n;i++){
		if(s[6][i] == '.'){
			if(s[6][i-1] == '#' or s[6][i+1] == '#'){
				s[5][i] = '#';
				r = i;
				break;
			}
		}
	}
	
	if(l > r) swap(l,r);
	
	if(l + 1 >= r){
		s[4][l] = '#';
	}
	else{
		for(int i=l+1;i<=r-1;i++) s[4][i] = '#';
	}
	
	cout << "Yes" << endl;
	for(int i=1;i<=7;i++){
		for(int j=1;j<=n;j++){
			cout << s[i][j];
		}
		cout << endl;
	}
	return ;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	
	int t; cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 8ms
memory: 3676kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.