QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#760802#9621. 连方xyzAC ✓26ms4360kbC++113.1kb2024-11-18 19:18:202024-11-18 19:18:21

Judging History

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

  • [2024-11-18 19:18:21]
  • 评测
  • 测评结果:AC
  • 用时:26ms
  • 内存:4360kb
  • [2024-11-18 19:18:20]
  • 提交

answer

#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
#define int long long
typedef long long ll; 

const int N = 1e5+10;


void solve()
{
    int n;
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    string ans[5];
    for(int i = 0;i<5;i++)
    {
        for(int j = 0;j<n;j++)
        {
            ans[i] += '.';
        }
    }

    for(int i = 1;i<=n;i++)
    {
        if(s1[i-1]=='#')
        {
            ans[0][i-1] = '.';
        }
        if(s1[i-1]=='.')
        {
            ans[0][i-1] = '#';
        }
        
        if(s2[i-1]=='#')
        {
            ans[4][i-1] = '.';
        }
        if(s2[i-1]=='.')
        {
            ans[4][i-1] = '#';
        }
    }
    
    int ok = 0,ok1 = 0;
    for(int i = 0;i<s1.size();i++)
    {
        if(s1[i]=='.')
        {
            ok = 1;
            break;
        }
    }
   
    for(int i = 0;i<s2.size();i++)
    {
        if(s2[i]=='.')
        {
            ok1 = 1;
            break;
        }
    }
    if(ok1+ok==1)
    {
        cout<<"No"<<endl;
        return;
    }
    if(ok1+ok==0)
    {
        cout<<"Yes"<<endl;
        cout<<s1<<endl;
        cout<<s1<<endl;
        cout<<s1<<endl;
        cout<<s1<<endl;
        cout<<s1<<endl;
        cout<<s1<<endl;
        cout<<s2<<endl;
        return;
    }


    int l = 0,r = 0;
    int le = 0,ri = 0;
    if(ans[0][0]=='#')
    {
        for(int i = 0;i<n;i++)
        {
            if(ans[0][i]=='.')
            {
                l = i-1;
                le = 1;
                break;
            }
        }
    }
    else{
        for(int i = 0;i<n;i++)
        {
            if(ans[0][i]=='#')
            {
                l = i;
                le = -1;
                break;
            }
        }
    }

    if(ans[4][0]=='#')
    {
        for(int i = 0;i<n;i++)
        {
            if(ans[4][i]=='.')
            {
                r = i-1;
                ri = 1;
                break;
            }
        }
    }
    else{
        for(int i = 0;i<n;i++)
        {
            if(ans[4][i]=='#')
            {
                r = i;
                ri = -1;
                break;
            }
        }
    }

    


    l+=le;
    r+=ri;
    ans[1][l] = '#';
    ans[3][r] = '#';


    if(l==r)
    {
        ans[2][l] = '#';
    }
    else if(abs(r-l)==1)
    {
       ans[2][l]= '#';
    }
    else if(l+1!=r&&l<r)
    {
        for(int i = l+1;i<r;i++)
        {
            ans[2][i] = '#';
        }
    }
    else if(l+1!=r&&l>r){

        for(int i = r+1;i<l;i++)
        {
            ans[2][i] = '#';
        }
    }
    cout<<"Yes"<<endl;
    cout<<s1<<endl;
    for(int i = 0;i<5;i++)
    {
        cout<<ans[i]<<endl;
    }
    cout<<s2<<endl;
    return;



}
signed main(){
    int _ = 1;
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
    cin>>_;
    while(_--){
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3560kb

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 8ms
memory: 3636kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 16ms
memory: 3936kb

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

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.