QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#739713#9621. 连方peiyangwjxAC ✓21ms4544kbC++202.1kb2024-11-12 22:47:302024-11-12 22:47:34

Judging History

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

  • [2024-11-12 22:47:34]
  • 评测
  • 测评结果:AC
  • 用时:21ms
  • 内存:4544kb
  • [2024-11-12 22:47:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
char s[10][200010];
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        scanf("%s",s[1]);
        scanf("%s",s[7]);
        int yi=0,er=0;
        for(int i=0;i<n;i++){
            if(s[1][i]=='.')yi=1;
            if(s[7][i]=='.')er=1;
        }
        if(yi==0&&er==0){
            cout<<"Yes"<<'\n';
            for(int i=1;i<=7;i++){
                for(int j=0;j<n;j++){
                    cout<<s[1][j];
                }
                cout<<'\n';
            }
            continue;
        }
        if(yi==0||er==0){
            cout<<"No"<<'\n';
            continue;
        }
        for(int i=0;i<n;i++){
            if(s[1][i]=='.')s[2][i]='#';
            else s[2][i]='.';
            if(s[7][i]=='.')s[6][i]='#';
            else s[6][i]='.';
        }
        int pos3=0,pos5=0;
        if(s[2][0]=='.'&&s[2][1]=='#')pos3=0;
        if(s[2][n-1]=='.'&&s[2][n-2]=='#')pos3=n-1;
        if(s[6][0]=='.'&&s[6][1]=='#')pos5=0;
        if(s[6][n-1]=='.'&&s[6][n-2]=='#')pos5=n-1;
        for(int i=1;i<n-1;i++){
            if(s[2][i]=='.'&&(s[2][i+1]=='#'||s[2][i-1]=='#'))pos3=i;
            if(s[6][i]=='.'&&(s[6][i+1]=='#'||s[6][i-1]=='#'))pos5=i;
        }
        for(int i=0;i<n;i++){
            if(i==pos3)s[3][i]='#';
            else s[3][i]='.';
            if(i==pos5)s[5][i]='#';
            else s[5][i]='.';
        }
        if(pos3==pos5){
            for(int i=0;i<n;i++){
                if(i==pos3)s[4][i]='#';
                else s[4][i]='.';
            }
        }else if(abs(pos3-pos5)==1){
            for(int i=0;i<n;i++){
                if(i==pos3)s[4][i]='#';
                else s[4][i]='.';
            }
        }else{
            for(int i=0;i<n;i++){
                if(i<max(pos3,pos5)&&i>min(pos3,pos5))s[4][i]='#';
                else s[4][i]='.';
            }
        }
        cout<<"Yes"<<'\n';
        for(int i=1;i<=7;i++){
            for(int j=0;j<n;j++){
                cout<<s[i][j];
            }
            cout<<'\n';
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 14ms
memory: 3852kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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

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

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 13ms
memory: 4344kb

input:

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

output:

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

result:

ok Correct.