QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#762781#9621. 连方xdz_AC ✓29ms10060kbC++141.7kb2024-11-19 16:37:282024-11-19 16:37:30

Judging History

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

  • [2024-11-19 16:37:30]
  • 评测
  • 测评结果:AC
  • 用时:29ms
  • 内存:10060kb
  • [2024-11-19 16:37:28]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define int long long 
#define se second
#define fi first 
#define endl '\n'
const int N = 1e5 + 10;
int a[10][N];
void solve(){
	int n;
	cin>>n;
	for(int i = 1; i <= 7;i ++){
		for(int j = 0;j <= n + 1;j ++) a[i][j] = 0;
	}
	string s1,s2;
	cin>>s1>>s2;
	int p1 = 0,p2 = 0;
	s1 = " " + s1;
	s2 = " " + s2;
	for(int i = 1;i <= n;i ++){
		if(s1[i] == '.'){
			p1 = 1;
			a[1][i] = 0;
		}
		else a[1][i] = 1;
		if(s2[i] == '.') {
			p2 = 1;
			a[7][i] = 0;
		}
		else a[7][i] = 1;
	}
	if(p1 == 0 && p2 == 0){
		cout<<"Yes"<<endl;
		for(int i = 1;i <= 7;i ++){
			for(int j = 1;j <= n;j ++) cout<<"#";
			cout<<endl;
		}
		return ;
	}
	if(p1 == 0 || p2 == 0){
		cout<<"No"<<endl;
		return ;
	} 
	for(int i = 1;i <= n;i ++) {
		if(a[1][i] == 0) a[2][i] = 1;
		if(a[7][i] == 0) a[6][i] = 1;
	}
	int pos1 = 0,pos2 = 0;
	for(int i = 1;i <= n;i ++){
		if(a[2][i] == 0 && (a[2][i - 1] == 1 || a[2][i + 1] == 1)){
			a[3][i] = 1;
			pos1 = i;
			break;
		}
	}
	for(int i = 1;i <= n;i ++){
		if(a[6][i] == 0 && (a[6][i - 1] == 1 || a[6][i + 1] == 1) ){
			a[5][i] = 1;
			pos2 = i;
			break;
		}
	}
//	cout<<pos1<<" "<<pos2<<endl;
	if(pos1 > pos2) swap(pos1,pos2);
	if(pos1 == pos2){
		a[4][pos1] = 1;
	}
	else if(pos1 + 1 == pos2){
		a[4][pos1] = 1;
	}
	else{
		for(int i = min(pos1,pos2) + 1;i < max(pos1,pos2);i ++){
			a[4][i] = 1;
		}
	}
	cout<<"Yes"<<endl;
	for(int i = 1; i <= 7;i ++){
		for(int j = 1;j <= n;j ++) {
			if(a[i][j] == 0) cout<<".";
			else cout<<"#";
		}
		cout<<endl;
	}
	
	
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	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: 7692kb

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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: 19ms
memory: 7860kb

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 28ms
memory: 10040kb

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: 29ms
memory: 9688kb

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 29ms
memory: 10056kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 28ms
memory: 10060kb

input:

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

output:

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

result:

ok Correct.