QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#740085#9621. 连方sixx_oneeAC ✓21ms4352kbC++202.3kb2024-11-13 00:57:112024-11-13 00:57:14

Judging History

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

  • [2024-11-13 00:57:14]
  • 评测
  • 测评结果:AC
  • 用时:21ms
  • 内存:4352kb
  • [2024-11-13 00:57:11]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 2e5 + 10;

char a[8][N];

int n;

void aa()
{
    puts("Yes");
    for (int i = 1; i <= 7; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            putchar(a[i][j]);
        }
        puts("");
    }
}

void solve()
{
    cin >> n;
    scanf("%s", a[1] + 1);
    scanf("%s", a[7] + 1);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 2; j <= 6; j++)
        {
            a[j][i] = '.';
        }
    }
    int qj1 = 1, qj7 = 1,qd1=1,qd7=1;
    for (int i = 1; i <= n; i++)
    {
        if (a[1][i] == '#')
            qd1 = 0;
        if (a[7][i] == '#')
            qd7 = 0;
        if (a[1][i] == '.')
            qj1 = 0;
        if (a[7][i] == '.')
            qj7 = 0;
    }

    if (qj1 & qj7)
    {
        for (int i = 1; i <= n; i++)
        {
            for (int j = 2; j <= 6; j++)
            {
                a[j][i] = '#';
            }
        }
        aa();
        return;
    }
    if ((qj1&&!qd7)||(qj7&&!qd1))
    {
        puts("No");
        return;
    }
    if((qj1&&qd7)||(qj7&&qd1))
    {
        aa();
        return;
    }


    for (int i = 1; i <= n; i++)
    {
        if (a[1][i] == '#')
            a[2][i] = '.';
        else
            a[2][i] = '#';
        if (a[7][i] == '#')
            a[6][i] = '.';
        else
            a[6][i] = '#';
    }

    int flag1 = 0, flag2 = 0;
    for (int i = 1; i <= n; i++)
    {
        if (flag1 && flag2)
            break;
        if (!flag1 && a[2][i] == '.' && (a[2][i - 1] == '#' || a[2][i + 1] == '#'))
        {
            a[3][i] = '#';
            flag1 = i;
        }
        if (!flag2 && a[6][i] == '.' && (a[6][i - 1] == '#' || a[6][i + 1] == '#'))
        {
            a[5][i] = '#';
            flag2 = i;
        }
    }
    if (!flag1 || !flag2)
    {
        aa();
        return;
    }
    if (flag1 > flag2)
        swap(flag1, flag2);
    if (flag2 - flag1 <= 1)
        a[4][flag1] = '#';
    else
    {
        for (int i = flag1 + 1; i <= flag2 - 1; i++)
        {
            a[4][i] = '#';
        }
    }

    aa();
}

signed main()
{
    int tt = 1;
    cin >> tt;
    while (tt--)
    {
        solve();
    }
}

詳細信息

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

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

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.