QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#737288#9621. 连方josoAC ✓11ms4004kbC++142.4kb2024-11-12 15:20:242024-11-12 15:20:25

Judging History

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

  • [2024-11-12 15:20:25]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:4004kb
  • [2024-11-12 15:20:24]
  • 提交

answer

#include <iostream>
#include <cstring>
#include <string>
#include <vector>

const int N = 2e5 + 10;

int n;
std::string a, b;
bool st1[N], st2[N];

void solve() {
    memset(st1, false, sizeof(bool) * (n + 1));
    memset(st2, false, sizeof(bool) * (n + 1));

    std::cin >> n >> a >> b;
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < n; i ++) {
        if (a[i] == '.') st1[i] = true;
        else cnt1 ++;
        if (b[i] == '.') st2[i] = true;
        else cnt2 ++;
    }

    if (cnt1 == n || cnt2 == n) {
        if (cnt1 != n || cnt2 != n) std::cout << "No\n";
        else {
            std::cout << "Yes\n";
            for (int i = 1; i <= 7; i ++)
                std::cout << a << '\n';
        }
        return;
    }

    int pos1, pos2;
    for (pos1 = 0; pos1 < n; pos1 ++) {
        if (!st1[pos1]) {
            if (pos1 > 0 && st1[pos1 - 1]) break;
            if (pos1 < n - 1 && st1[pos1 + 1]) break;
        }
    }
    for (pos2 = 0; pos2 < n; pos2 ++) {
        if (!st2[pos2]) {
            if (pos2 > 0 && st2[pos2 - 1]) break;
            if (pos2 < n - 1 && st2[pos2 + 1]) break;
        }
    }

    std::cout << "Yes\n";
    std::cout << a << '\n';
    for (int i = 0; i < n; i ++)
        if (st1[i]) std::cout.put('#');
        else std::cout.put('.');
    std::cout.put('\n');
    for (int i = 0; i < n; i ++)
        if (i == pos1) std::cout.put('#');
        else std::cout.put('.');
    std::cout.put('\n');

    if (pos1 == pos2 || pos1 == pos2 + 1 || pos1 == pos2 - 1) {
        for (int i = 0; i < n; i ++)
            if (i == pos1) std::cout.put('#');
            else std::cout.put('.');
    } else {
        int min = std::min(pos1, pos2), max = std::max(pos1, pos2);
        for (int i = 0; i < n; i ++)
            if (i > min && i < max) std::cout.put('#');
            else std::cout.put('.');
    }
    std::cout.put('\n');

    for (int i = 0; i < n; i ++)
        if (i == pos2) std::cout.put('#');
        else std::cout.put('.');
    std::cout.put('\n');
    for (int i = 0; i < n; i ++)
        if (st2[i]) std::cout.put('#');
        else std::cout.put('.');
    std::cout.put('\n');
    std::cout << b << '\n';
}

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

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

    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 11ms
memory: 3724kb

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

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 11ms
memory: 4004kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 11ms
memory: 3920kb

input:

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

output:

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

result:

ok Correct.