QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#742183#9621. 连方ty09#AC ✓7ms4548kbC++171.7kb2024-11-13 16:02:362024-11-13 16:02:39

Judging History

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

  • [2024-11-13 16:02:39]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:4548kb
  • [2024-11-13 16:02:36]
  • 提交

answer

#include"bits/stdc++.h"
#define endl '\n'
using ll=long long;
using namespace std;
constexpr int N=1e5+10,inf=0X3F3F3F3F;
constexpr ll INF=0X3F3F3F3F3F3F3F3F;
void solve(){
    int n;
    cin>>n;
    string t,y;
    for(int i=0;i<n;i++){
        t.push_back('#');
        y.push_back('.');
    }
    string a,b;
    cin>>a>>b;
    if((a==t)^(b==t)){
        cout<<"No"<<endl;
        return;
    }else if(a==t and b==t){
        cout<<"Yes"<<endl;
        for(int i=0;i<7;i++)
            cout<<t<<endl;
        return;
    }
    vector<string>mp(7);

    mp[0]=a;
    mp[6]=b;

    mp[1].resize(n);
    for(int i=0;i<n;i++){
        if(a[i]=='.')
            mp[1][i]='#';
        else
            mp[1][i]='.';
    }

    mp[5].resize(n);
    for(int i=0;i<n;i++){
        if(b[i]=='.')
            mp[5][i]='#';
        else
            mp[5][i]='.';
    }

    int u=-1,v=-1;
    for(int i=0;i<n;i++){
        if(mp[1][i]=='.' and ((i>0 and mp[1][i-1]=='#')or(i<n-1 and mp[1][i+1]=='#'))){
            u=i;
            break;
        }
    }
    for(int i=0;i<n;i++){
        if(mp[5][i]=='.' and ((i>0 and mp[5][i-1]=='#')or(i<n-1 and mp[5][i+1]=='#'))){
            v=i;
            break;
        }
    }
    mp[2]=y;
    mp[4]=y;
    mp[2][u]='#';
    mp[4][v]='#';

    mp[3]=y;
    if(u==v){
        mp[3][u]='#';
    }else if(min(u,v)+1==max(u,v)){
        mp[3][u]='#';
    }else{
        for(int i=min(u,v)+1;i<max(u,v);i++)
            mp[3][i]='#';
    }
    
    cout<<"Yes"<<endl;
    for(int i=0;i<7;i++){
        cout<<mp[i]<<endl;
    }
}
signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
	int t;cin>>t;while(t--)
    solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 0ms
memory: 4548kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 3ms
memory: 4528kb

input:

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

output:

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

result:

ok Correct.