QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#750811#9621. 连方suzuAC ✓7ms3988kbC++232.5kb2024-11-15 16:02:452024-11-15 16:02:47

Judging History

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

  • [2024-11-15 16:02:47]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:3988kb
  • [2024-11-15 16:02:45]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void solve()
{
    int n;
    std::cin >> n;
    std::vector<std::string> s(8);
    std::cin >> s[1] >> s[7];
    std::string a = std::string(n, '#');
    if (s[1] == s[7] && s[1] == a) {
        std::cout << "Yes\n";
        for (int i = 1; i <= 7; i++) {
            std::cout << s[1] << "\n";
        }
        return;
    }
    if (s[1] == a || s[7] == a) {
        std::cout << "No\n";
        return;
    }
    for (int i = 2; i <= 6; i++) {
        s[i].resize(n);
    }
    for (int i = 0; i < n; i++) {
        if (s[1][i] == '.') {
            s[2][i] = '#';
        } else {
            s[2][i] = '.';
        }
        if (s[7][i] == '.') {
            s[6][i] = '#';
        } else {
            s[6][i] = '.';
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 3; j <= 5; j++) {
            s[j][i] = '.';
        }
    }
    int l = 1e9, r = 1e9;
    for (int i = 0; i < n; i++) {
        if (s[2][i] == '.') {
            if ((i - 1 >= 0 && s[2][i - 1] == '#') || (i + 1 < n && s[2][i + 1] == '#')) {
                s[3][i] = '#';
                l = i;
                break;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (s[6][i] == '.') {
            if ((i - 1 >= 0 && s[6][i - 1] == '#') || (i + 1 < n && s[6][i + 1] == '#')) {
                s[5][i] = '#';
                r = i;
                break;
            }
        }
    }
    if (l == 1e9 || r == 1e9) {
        std::cout << "No\n";
        return;
    }
    // if (std::abs(r - l) == 1) {
    //     std::cout << "No\n";
    //     return;
    // }
    if (l == r) {
        s[4][l] = '#';
    } else if (l < r) {
        if (r - l == 1) {
            s[4][l] = '#';
        } else {
            for (int i = l + 1; i < r; i++) {
                s[4][i] = '#';
            }
        }
        
    } else {
        if (l - r == 1) {
            s[4][r] = '#';
        } else {
            for (int i = r + 1; i < l; i++) {
                s[4][i] = '#';
            } 
        }
    }
    std::cout << "Yes\n";
    for (int i = 1; i <= 7; i++) {
        std::cout << s[i] << "\n";
    }
}
/*
4
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
*/

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int _ = 1;
    std::cin >> _;
    while (_--) {
        solve();
    }

   return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 7ms
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: 7ms
memory: 3704kb

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.