QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#746199#9621. 连方Yurily#AC ✓23ms4336kbC++201.7kb2024-11-14 13:48:572024-11-14 13:48:59

Judging History

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

  • [2024-11-14 13:48:59]
  • 评测
  • 测评结果:AC
  • 用时:23ms
  • 内存:4336kb
  • [2024-11-14 13:48:57]
  • 提交

answer

#include<iostream>
using namespace std;

int n,s3,s5,l,r;
char s[10][100010];

int main(){
    
    int T; cin>>T;
    while(T--){
        cin>>n;
        cin>>s[1];
        cin>>s[7];
        bool tf1=1,tf2=1;
        for(int i=0;i<n;i++){
            if(s[1][i]=='.') tf1=0;
        }
        for(int i=0;i<n;i++){
            if(s[7][i]=='.') tf2=0;
        }
        if((tf1^tf2)==1){
            cout<<"No\n";
            continue;
        }
        if(tf1==1&&tf2==1){
            cout<<"Yes\n";
            for(int i=1;i<=7;i++){
                cout<<s[1]<<"\n";
            }
            continue;
        }
        for(int i=0;i<n;i++){
            if(s[1][i]=='#') s[2][i]='.';
            if(s[1][i]=='.') s[2][i]='#';
            if(s[7][i]=='#') s[6][i]='.';
            if(s[7][i]=='.') s[6][i]='#';
        }
        bool t3=1,t5=1;
        for(int i=0;i<n-1;i++){
            if(t3&&s[2][i]!=s[2][i+1]){
                if(s[2][i]=='.') s3=i;
                else s3=i+1;
                t3=0;
            }
            if(t5&&s[6][i]!=s[6][i+1]){
                if(s[6][i]=='.') s5=i;
                else s5=i+1;
                t5=0;
            }
        }
        if(s3==s5) l=s3,r=s3;
        else if(abs(s3-s5)==1) l=s3,r=s3;
        else l=min(s3,s5)+1,r=max(s3,s5)-1;
        for(int i=3;i<=5;i++){
            for(int j=0;j<n;j++){
                if(i==3&&j==s3) s[i][j]='#';
                else if(i==4&&j>=l&&j<=r) s[i][j]='#';
                else if(i==5&&j==s5) s[i][j]='#';
                else s[i][j]='.';
            }
        }
        cout<<"Yes\n";
        for(int i=1;i<=7;i++){
            for(int j=0;j<n;j++) cout<<s[i][j];
            cout<<"\n";
        }
    }
}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 23ms
memory: 3644kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 20ms
memory: 4256kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 21ms
memory: 4336kb

input:

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

output:

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

result:

ok Correct.