QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#746792#9621. 连方yzhang#AC ✓15ms3944kbC++232.5kb2024-11-14 15:34:082024-11-14 15:34:10

Judging History

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

  • [2024-11-14 15:34:10]
  • 评测
  • 测评结果:AC
  • 用时:15ms
  • 内存:3944kb
  • [2024-11-14 15:34:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int T,n;
string s[10];
int main(){
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    cin>>T;
    while(T--){
        cin>>n>>s[1]>>s[7];
        for(int i=2;i<=6;++i){
            s[i]=s[1];
            for(int j=0;j<n;++j) s[i][j]='.';
        }
        int bg1=-1,ed1=-2;
        int bg2=-1,ed2=-2;
        for(int i=0;i<n;++i){
            if(s[1][i]=='.'){
                if(bg1==-1) bg1=ed1=i;
                else if(ed1==i-1) ed1=i;
            }
            if(s[7][i]=='.'){
                if(bg2==-1) bg2=ed2=i;
                else if(ed2==i-1) ed2=i;
            }
        }
        if(bg1==-1){
            if(bg2==-1){
                for(int i=2;i<=6;++i) s[i]=s[1];
                cout<<"Yes\n";
                for(int i=1;i<=7;++i)
                    cout<<s[i]<<'\n';
            }else if(bg2==0&&ed2==n-1){
                cout<<"Yes\n";
                for(int i=1;i<=7;++i)
                    cout<<s[i]<<'\n';
            }else{
                cout<<"No\n";
            }
        }else if(bg2==-1){
            if(bg1==-1||(bg1==0&&ed1==n-1)){
                cout<<"Yes\n";
                for(int i=1;i<=7;++i)
                    cout<<s[i]<<'\n';
            }else{
                cout<<"No\n";
            }
        }else if(bg1==0&&ed1==n-1){
            for(int i=0;i<n;++i){
                // if(s[1][i]=='.') s[2][i]='#';
                if(s[7][i]=='.') s[6][i]='#';
            }
            cout<<"Yes\n";
            for(int i=1;i<=7;++i) cout<<s[i]<<'\n';
        }else if(bg2==0&&ed2==n-1){
            for(int i=0;i<n;++i){
                if(s[1][i]=='.') s[2][i]='#';
                // if(s[7][i]=='.') s[6][i]='#';
            }
            cout<<"Yes\n";
            for(int i=1;i<=7;++i) cout<<s[i]<<'\n';
        }else{
            // cerr<<"fk\n";
            for(int i=0;i<n;++i){
                if(s[1][i]=='.') s[2][i]='#';
                if(s[7][i]=='.') s[6][i]='#';
            }
            int p1=bg1-1;
            if(p1<0) p1=ed1+1;
            int p2=bg2-1;
            if(p2<0) p2=ed2+1;
            s[3][p1]='#',s[5][p2]='#';
            if(p1>p2) swap(p1,p2);
            if(p1==p2){
                s[4][p1]='#';
            }else if(p1==p2-1){
                s[4][p1]='#';
            }else{
                for(int i=p1+1;i<=p2-1;++i)
                    s[4][i]='#';
            }
            cout<<"Yes\n";
            for(int i=1;i<=7;++i) cout<<s[i]<<'\n';
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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

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

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 9ms
memory: 3896kb

input:

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

output:

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

result:

ok Correct.