QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#760066#9621. 连方1205691775#AC ✓18ms4104kbC++201.8kb2024-11-18 14:30:492024-11-18 14:30:50

Judging History

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

  • [2024-11-18 14:30:50]
  • 评测
  • 测评结果:AC
  • 用时:18ms
  • 内存:4104kb
  • [2024-11-18 14:30:49]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void solve(){
    int n;
    std::cin >> n;
    std::vector<std::string> mp(7);
    std::cin >> mp[0] >> mp[6];

    for (int i = 1; i < 6; ++i) {
        mp[i] = std::string(n, '.');
    }
    std::string full(n, '#');
    if (mp[0] == full && full == mp[6]) {
        std::cout << "Yes\n";
        for (int i = 0; i < 7; ++i) {
            std::cout << mp[0] << "\n";
        }
        return;
    }
    if (mp[0] == full || mp[6] == full) {
        std::cout << "No\n";
        return;
    }


    for (int i = 0; i < n; ++i) {
        mp[1][i] = mp[0][i] == '#' ? '.' : '#';
    }
    for (int i = 0; i < n; ++i) {
        mp[5][i] = mp[6][i] == '#' ? '.' : '#';
    }

    int x0 = -1, x1 = -1;
    for (int i = 0; i + 1 < n; ++i) {
        if (mp[0].substr(i, 2) == "#.") {
            x0 = i;
            break;
        } else if (mp[0].substr(i, 2) == ".#") {
            x0 = i + 1;
            break;
        }
    }

    for (int i = 0; i + 1 < n; ++i) {
        if (mp[6].substr(i, 2) == "#.") {
            x1 = i;
            break;
        } else if (mp[6].substr(i, 2) == ".#") {
            x1 = i + 1;
            break;
        }
    }

    assert(x0 != -1 && x1 != -1);

    mp[2][x0] = '#';
    mp[4][x1] = '#';

    if (x0 > x1) std::swap(x0, x1);

    if (x0 == x1 || x0 + 1 == x1) {
        mp[3][x0] = '#';
    } else {
        for (int i = x0 + 1; i < x1; ++i) {
            mp[3][i] = '#';
        }
    }


    std::cout << "Yes\n";
    for (int i = 0; i < 7; ++i) {
        std::cout << mp[i] << "\n";
    }
}

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


    int t;
    std::cin >> t;
    while(t--){
        solve();
    }

    return 0;
}

详细

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 18ms
memory: 3612kb

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 6ms
memory: 4104kb

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.