QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#751807#9621. 连方LinZhengyu#AC ✓7ms3792kbC++141.5kb2024-11-15 20:48:332024-11-15 20:48:34

Judging History

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

  • [2024-11-15 20:48:34]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:3792kb
  • [2024-11-15 20:48:33]
  • 提交

answer

#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::string;
typedef long long lli;

int n;
string s1,s2,so;
int i1,i2;
bool m1,m2;
inline bool ck(string &s) {
	for(int i=0;i<s.length();++i)if(s[i]=='.')return 0;
	return 1;
}
inline int ib(int x){return x>0?x:-x;}

inline void solve() {
	cin>>n>>s1>>s2;
	m1=ck(s1),m2=ck(s2);
	if(m1^m2) {
		cout<<"No"<<'\n';
		return;
	}
	cout<<"Yes"<<'\n';
	if(m1&&m2) {
		for(int i=1;i<=7;++i) {
			for(int j=1;j<=n;++j)cout<<'#';
			cout<<'\n';
		}
		return;
	}

	for(int i=1;i<n;++i)if(s1[i-1]=='#'&&s1[i]=='.')i1=i-1;
	for(int i=1;i<n;++i)if(s1[i-1]=='.'&&s1[i]=='#')i1=i;
	for(int i=1;i<n;++i)if(s2[i-1]=='#'&&s2[i]=='.')i2=i-1;
	for(int i=1;i<n;++i)if(s2[i-1]=='.'&&s2[i]=='#')i2=i;
	cout<<s1<<'\n';
	so=s1;
	for(int i=0;i<n;++i)if(so[i]=='.')so[i]='#';else so[i]='.';
	cout<<so<<'\n';
	for(int i=0;i<n;++i)if(i==i1)so[i]='#';else so[i]='.';
	cout<<so<<'\n';
	for(int i=0;i<n;++i) {
		if(ib(i1-i2)>=2) {
			if(i1<i&&i<i2||i2<i&&i<i1)so[i]='#';else so[i]='.';
		}
		else {
			if(i1==i)so[i]='#';else so[i]='.';
		}
	}
	cout<<so<<'\n';
	for(int i=0;i<n;++i)if(i==i2)so[i]='#';else so[i]='.';
	cout<<so<<'\n';
	so=s2;
	for(int i=0;i<n;++i)if(so[i]=='.')so[i]='#';else so[i]='.';
	cout<<so<<'\n';
	cout<<s2<<'\n';
}
inline void clear() {
	i1=i2=0;
}

int main() {
	std::ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);

	int t;
	cin>>t;
	while(t--) {
		solve();
		clear();
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 7ms
memory: 3624kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 3ms
memory: 3696kb

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

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.