QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789975#9621. 连方NULL_SFAC ✓10ms4184kbC++172.3kb2024-11-27 23:19:412024-11-27 23:19:42

Judging History

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

  • [2024-11-27 23:19:42]
  • 评测
  • 测评结果:AC
  • 用时:10ms
  • 内存:4184kb
  • [2024-11-27 23:19:41]
  • 提交

answer

#include <iostream>

using namespace std;

void solve()
{
	int n,k3,k5;
	string s1,s7,s2,s6;
	cin>>n>>s1>>s7;
	
	s2.resize(n);
	s6.resize(n);
	
	//特判全空
	bool f=true;
	for(auto c:s1)
	{
		if(c=='#') f=false;
	}
	if(f)
	{
		cout<<"Yes\n";
		for(int i=1;i<=5;i++){
			for(int j=0;j<n;j++) cout<<'.';
			cout<<'\n';
		}
		for(auto c:s7){
			if(c=='.') cout<<'#';
			else cout<<'.';
		}
		cout<<'\n';
		for(auto c:s7){
			cout<<c;
		}
		cout<<'\n';
		
		return;
	}
	
	f=true;
	for(auto c:s7)
	{
		if(c=='#') f=false;
	}
	if(f)
	{
		cout<<"Yes\n";
		for(auto c:s1){
			cout<<c;
		}
		cout<<'\n';
		for(auto c:s1){
			if(c=='.') cout<<'#';
			else cout<<'.';
		}
		cout<<'\n';
		for(int i=1;i<=5;i++){
			for(int j=0;j<n;j++) cout<<'.';
			cout<<'\n';
		}
		
		return;
	}
	
	int cnt1=0;
	for(auto c:s1)
	{
		cnt1+=c=='.';
	}
	int cnt2=0;
	for(auto c:s7)
	{
		cnt2+=c=='.';
	}
	if(cnt1==0 && cnt2==0)
	{
		cout<<"Yes\n";
		for(int i=1;i<=7;i++){
			for(int j=0;j<n;j++) cout<<'#';
			cout<<'\n';
		}
		
		return;
	}
	
	for(int i=0;i<n;i++)
	{
		if(s1[i]=='#') s2[i]='.';
		else s2[i]='#';
		
		if(s7[i]=='#') s6[i]='.';
		else s6[i]='#';
	}
	
	bool flag=true;
	for(int i=0;i<n && flag;i++){
		if((s2[i]=='.' && ((i>0 && s2[i-1]=='#') || (i<n-1 && s2[i+1]=='#'))) || (s2[i]=='#' && (i==0 || s2[i-1]=='.') && (i==n-1 || s2[i+1]=='.')))
		{
			flag=false;
			k3=i;
		}
	}
	if(flag)
	{
		cout<<"No\n";
		return;
	}
	
	flag=true;
	for(int i=0;i<n && flag;i++){
		if((s6[i]=='.' && ((i>0 && s6[i-1]=='#') || (i<n-1 && s6[i+1]=='#'))) || (s6[i]=='#' && (i==0 || s6[i-1]=='.') && (i==n-1 || s6[i+1]=='.')))
		{
			flag=false;
			k5=i;
		}
	}
	if(flag)
	{
		cout<<"No\n";
		return;
	}
	
	cout<<"Yes\n";
	cout<<s1<<'\n'<<s2<<'\n';
	for(int i=0;i<n;i++){
		if(i==k3) cout<<'#';
		else cout<<'.';
	}
	cout<<'\n';
	for(int i=0;i<n;i++){
		if(i==k3 && abs(k3-k5)<=1) cout<<'#';
		else if(i>min(k3,k5) && i<max(k3,k5)) cout<<'#';
		else cout<<'.';
	}
	cout<<'\n';
	for(int i=0;i<n;i++){
		if(i==k5) cout<<'#';
		else cout<<'.';
	}
	cout<<'\n';
	cout<<s6<<'\n'<<s7<<'\n';
	
	return;
}

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

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.