QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#737465#9621. 连方Zxyoul#AC ✓8ms4192kbC++235.2kb2024-11-12 15:54:452024-11-12 15:54:45

Judging History

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

  • [2024-11-12 15:54:45]
  • 评测
  • 测评结果:AC
  • 用时:8ms
  • 内存:4192kb
  • [2024-11-12 15:54:45]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e6 + 5;
void solve()
{
    int n;
    cin >> n;
    vector<string> a(7, string(n, '.'));
    auto print = [&]()
    {
        cout << "Yes\n";
        for (int i = 0; i < 7; i++)
        {
            cout << a[i] << "\n";
        }
    };
    cin >> a[0] >> a[6];
    if (a[0] == string(n, '#') || a[6] == string(n, '#'))
    {
        if (a[0] == a[6])
        {
            for (int i = 1; i < 6; i++)
                a[i] = a[0];
            print();
            return;
        }
        cout << "No\n";
        return;
    }
    bool flag = 1;
    for (int i = 0; i < n; i++)
    {
        if (a[0][i] == a[6][i])
        {
            flag = 0;
            break;
        }
    }
    if (flag)
    {
        for (int i = 1; i < 6; i++)
            a[i] = a[0];
        print();
        return;
    }
    for (int i = 0; i < n; i++)
    {
        if (a[0][i] == '.')
            a[1][i] = '#';
        if (a[6][i] == '.')
            a[5][i] = '#';
    }
    if (a[0][0] == a[6][0] && a[0][0] == '.')
    {
        a[2][0] = a[3][0] = a[4][0] = '#';
        if (a[0][1] == '.')
        {
            a[1][0] = '.';
        }
        if (a[6][1] == '.')
        {
            a[5][0] = '.';
        }
        print();
        return;
    }
    if (a[0][n - 1] == a[6][n - 1] && a[0][n - 1] == '.')
    {
        a[2][n - 1] = a[3][n - 1] = a[4][n - 1] = '#';
        if (a[0][n - 2] == '.')
        {
            a[1][n - 1] = '.';
        }
        if (a[6][n - 2] == '.')
        {
            a[5][n - 1] = '.';
        }
        print();
        return;
    }
    a[1][0] = a[1][n - 1] = a[5][0] = a[5][n - 1] = '.';
    flag = 0;
    bool flaga = 0, flagb = 0;
    if (a[1].find('#') == string::npos)
    {
        flaga = 1;
        if (a[0][0] == '.')
            a[1][0] = '#';
        if (a[0][n - 1] == '.')
            a[1][n - 1] = '#';
    }
    if (a[5].find('#') == string::npos)
    {
        flagb = 1;
        if (a[6][0] == '.')
            a[5][0] = '#';
        if (a[6][n - 1] == '.')
            a[5][n - 1] = '#';
    }
    if (flaga)
    {
        if (a[1][0] == '#')
        {
            auto l = a[5].find('#');
            if (l == 1)
            {
                for (int j = 2; j < 5; j++)
                    a[j][0] = '#';
            }
            else
            {
                for (int j = 2; j < 5; j++)
                {
                    for (int k = 1; k < l; k++)
                    {
                        a[j][k] = '#';
                    }
                }
            }
        }
        else if (a[1][n - 1] == '#')
        {
            auto r = a[5].rfind('#');
            if (r + 1 == n - 1)
            {
                for (int j = 2; j < 5; j++)
                    a[j][n - 1] = '#';
            }
            else
            {
                for (int j = 2; j < 5; j++)
                {
                    for (int k = r+1; k < n - 1; k++)
                    {
                        a[j][k] = '#';
                    }
                }
            }
        }
        print();
        return;
    }
    if (flagb)
    {
        if (a[5][0] == '#')
        {
            auto l = a[1].find('#');
            if (l == 1)
            {
                for (int j = 2; j < 5; j++)
                    a[j][0] = '#';
            }
            else
            {
                for (int j = 2; j < 5; j++)
                {
                    for (int k = 1; k < l; k++)
                    {
                        a[j][k] = '#';
                    }
                }
            }
        }
        else if (a[5][n - 1] == '#')
        {
            auto r = a[1].rfind('#');
            if (r + 1 == n - 1)
            {
                for (int j = 2; j < 5; j++)
                    a[j][n - 1] = '#';
            }
            else
            {
                for (int j = 2; j < 5; j++)
                {
                    for (int k = r+1; k < n - 1; k++)
                    {
                        a[j][k] = '#';
                    }
                }
            }
        }
        print();
        return;
    }
    for (int i = 0; i < n; i++)
    {
        if (a[1][i] == '.')
            a[2][i] = '#';
        if (a[5][i] == '.')
            a[4][i] = '#';
    }
    if (a[1][0] == a[5][0] && a[1][0] == '.')
    {
        a[3][0] = '#';
        if (a[1][1] == '.')
        {
            a[2][0] = '.';
        }
        if (a[5][1] == '.')
        {
            a[4][0] = '.';
        }
        print();
        return;
    }
    if (a[1][n - 1] == a[5][n - 1] && a[1][n - 1] == '.')
    {
        a[3][n - 1] = '#';
        if (a[1][n - 2] == '.')
        {
            a[2][n - 1] = '.';
        }
        if (a[5][n - 2] == '.')
        {
            a[4][n - 1] = '.';
        }
        print();
        return;
    }
    assert(0);
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
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: 3620kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 2ms
memory: 3624kb

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

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.