QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#739701#9621. 连方Kopicy#AC ✓18ms4176kbC++232.0kb2024-11-12 22:44:082024-11-12 22:44:09

Judging History

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

  • [2024-11-12 22:44:09]
  • 评测
  • 测评结果:AC
  • 用时:18ms
  • 内存:4176kb
  • [2024-11-12 22:44:08]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define rep(i, a, b) for(int i=(a);i<=(b);++i)
#define per(i, a, b) for(int i=(a);i>=(b);--i)
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)x.size()
#define endl "\n"
const int N = 2e5 + 5, mod = 998244353, inf = 1e18;

void solve() {
    int n;
    cin>>n;
    vector a(8,vector<char>(n+2,'.'));
    rep(i,1,n){
        char x;
        cin>>x;
        a[1][i]=x;
    }
    rep(i,1,n){
        char x;
        cin>>x;
        a[7][i]=x;
    }

    auto chk=[&](int x){
        rep(i,1,n){
            if(a[x][i]=='.') return false;
        }
        return true;
    };
    if(chk(1) && chk(7)){
        cout<<"Yes"<<endl;
        rep(i,1,7){
            rep(j,1,n)cout<<'#';
            cout<<endl;
        }
        return;
    }
    rep(i,1,n){
        if(a[1][i]=='.') a[2][i]='#';
        if(a[1][i]=='#') a[2][i]='.';
    }
    rep(i,1,n){
        if(a[7][i]=='#') a[6][i]='.';
        if(a[7][i]=='.') a[6][i]='#';
    }

    int fl=-1,fr=-1;
    for(int i=1;i<=n;i++){
        if(a[2][i]=='.' && (a[2][i-1]=='#' || a[2][i+1]=='#')){
            fl=i;
            break;
        }
    }
    for(int i=1;i<=n;i++){
        if(a[6][i]=='.' && (a[6][i-1]=='#' || a[6][i+1]=='#')){
            fr=i;
            break;
        }
    }
    if(fl==-1 || fr==-1){
        cout<<"No\n";
        return;
    }

    cout<<"Yes\n";
    a[3][fl]='#';
    a[5][fr]='#';

    if(abs(fl-fr)<=1){
        a[4][fl]='#';
    }
    else{
        if(fl>fr) swap(fl,fr);
        rep(i,fl+1,fr-1){
            a[4][i]='#';
        }
    }
    rep(i,1,7){
        rep(j,1,n)cout<<a[i][j];
        cout<<endl;
    }
}

signed main() {
    IOS
    int64_t tt = 1;
    cin >> tt;
    rep(kase, 1, tt) solve();
}
/*
4
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 14ms
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: 3716kb

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 11ms
memory: 4176kb

input:

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

output:

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

result:

ok Correct.