QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#744554#9621. 连方dmrmra#AC ✓10ms4396kbC++112.1kb2024-11-13 22:23:492024-11-13 22:23:50

Judging History

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

  • [2024-11-13 22:23:50]
  • 评测
  • 测评结果:AC
  • 用时:10ms
  • 内存:4396kb
  • [2024-11-13 22:23:49]
  • 提交

answer

//
// Created by 16373 on 2024/11/13.
//
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;
char x[10][100005];
void solve(){
    int n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    bool aq=true,bq=true;
    for(int i=0;i<n-1;++i)
    {
        if(a[i]!=a[i+1]) aq=false;
        if(b[i]!=b[i+1]) bq=false;
    }
    if(aq&&bq)
    {
        cout<<"Yes\n";
        cout<<a<<"\n";
        for(int i=0;i<5;++i)
        {
            for(int j=0;j<n;++j)
            {
                cout<<'#';
            }
            cout<<"\n";
        }
        cout<<b<<"\n";
        return;
    }
    else if(aq||bq)
    {
        cout<<"No\n";
        return;
    }
    for(int i=0;i<n;++i)
    {
        x[1][i]=(a[i]=='#'?'.':'#');
        x[5][i]=(b[i]=='#'?'.':'#');
    }
    for(int i=0;i<n;++i)
    {
        x[2][i]='.';
        x[4][i]='.';
    }
    int l,r;
    for(int i=0;i<n;++i)
    {
        if(x[1][i]=='.'&&((i-1>=0&&x[1][i-1]=='#')||(i+1<n&&x[1][i+1]=='#')))
        {
            x[2][i]='#';
            l=i;
            break;
        }
    }
    for(int i=0;i<n;++i)
    {
        if(x[5][i]=='.'&&((i-1>=0&&x[5][i-1]=='#')||(i+1<n&&x[5][i+1]=='#')))
        {
            x[4][i]='#';
            r=i;
            break;
        }
    }
    for(int i=0;i<n;++i)
    {
        x[3][i]='.';
    }
    if(l>r) swap(l,r);
    if(l==r||l==r-1)
    {
        x[3][l]='#';
    }
    else {
        for (int i = l + 1; i < r;++i)
        {
            x[3][i]='#';
        }
    }
    cout<<"Yes\n";
    cout<<a<<'\n';
    for(int i=1;i<=5;i++){
        for(int j=0;j<n;j++){
            cout<<x[i][j];
        }
        cout<<'\n';
    }
    cout<<b<<'\n';
    //cout<<a<<"\n"<<x[1]<<"\n"<<x[2]<<"\n"<<x[3]<<"\n"<<x[4]<<"\n"<<x[5]<<"\n"<<b<<"\n";
}
signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
/*
4
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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: 10ms
memory: 3620kb

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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: 10ms
memory: 3896kb

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.