QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#751437#9621. 连方zenglxAC ✓17ms4400kbC++202.0kb2024-11-15 18:41:052024-11-15 18:41:07

Judging History

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

  • [2024-11-15 18:41:07]
  • 评测
  • 测评结果:AC
  • 用时:17ms
  • 内存:4400kb
  • [2024-11-15 18:41:05]
  • 提交

answer

#include <bits/stdc++.h>
#define endl '\n'
#define int long long
// #define i128 __int128
using namespace std;
typedef long long ll;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;

int n;
char mp[10][N];

void solve(){
	cin>>n;
	int cnt=0;
	for(int i=2;i<=6;i++){
    	for(int j=1;j<=n;j++){
    		mp[i][j]='.';
    	}
    }
    bool sg1=false,sg2=false;
    for(int i=1;i<=n;i++){
    	cin>>mp[1][i];
    	if(mp[1][i]=='.'){
    		mp[2][i]='#';
    		cnt++;
    	}
    }
    if(cnt==0)
    	sg1=true;
    cnt=0;
    for(int i=1;i<=n;i++){
    	cin>>mp[7][i];
    	if(mp[7][i]=='.'){
    		mp[6][i]='#';
    		cnt++;
    	}
    }
    if(cnt==0)
    	sg2=true;
    if(sg1^sg2){
    	cout<<"NO"<<endl;
    	return;
    }
    cout<<"YES"<<endl;
    if(sg1&&sg2){
    	for(int i=1;i<=7;i++){
    		for(int j=1;j<=n;j++){
    			cout<<mp[1][j];
    		}
    		cout<<endl;
    	}
    }else{
    	int pos1,pos2;
    	for(int i=1;i<=n;i++){
    		if(mp[2][i]=='.'){
    			if(i>=2&&mp[2][i-1]=='#'){
    				pos1=i;
    				break;
    			}else if(i<=n-1&&mp[2][i+1]=='#'){
    				pos1=i;
    				break;
    			}
    		}
    	}
    	for(int i=1;i<=n;i++){
    		if(mp[6][i]=='.'){
    			if(i>=2&&mp[6][i-1]=='#'){
    				pos2=i;
    				break;
    			}else if(i<=n-1&&mp[6][i+1]=='#'){
    				pos2=i;
    				break;
    			}
    		}
    	}
    	mp[3][pos1]='#';
    	mp[5][pos2]='#';
    	if(pos1==pos2){
    		mp[4][pos1]='#';
    	}else if(abs(pos1-pos2)==1){
    		mp[4][pos1]='#';
    	}else{
    		for(int i=min(pos1,pos2)+1;i<max(pos1,pos2);i++){
    			mp[4][i]='#';
    		}
    	}
    	for(int i=1;i<=7;i++){
    		for(int j=1;j<=n;j++){
    			cout<<mp[i][j];
    		}
    		cout<<endl;
    	}
    }
    return;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout<<setiosflags(ios::fixed)<<setprecision(1);
    int T=1;cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

YES
#..#
.##.
#...
#...
.#..
#..#
.##.
YES
##.#.
..#.#
.#...
.#...
.#...
#.#..
.#.##
NO
YES
.######.######.####.#.#####
#......#......#....#.#.....
.#.........................
.#.........................
.#.........................
#....###....##.#######.....
.####...####..#.......#####
YES
########...

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 15ms
memory: 3732kb

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

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

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

input:

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

output:

NO
YES
###...
...###
..#...
..#...
.#....
..##.#
##..#.
YES
.#.######
#.#......
.#.......
.#.......
#........
.#.##....
#.#..####
YES
######.##########################################
......#..........................................
.....#...........................................
......#............

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 16ms
memory: 4284kb

input:

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

output:

YES
###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 16ms
memory: 4400kb

input:

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

output:

YES
##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........

result:

ok Correct.