QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789909#9621. 连方goukAC ✓15ms4524kbC++202.1kb2024-11-27 22:40:552024-11-27 22:40:57

Judging History

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

  • [2024-11-27 22:40:57]
  • 评测
  • 测评结果:AC
  • 用时:15ms
  • 内存:4524kb
  • [2024-11-27 22:40:55]
  • 提交

answer

#include <bits/stdc++.h>
// #define int long long
#define debug cout << "------------------------------" << endl

using namespace std;

void solve() {
    int n;
    string a, b;
    cin >> n >> a >> b;
    int na = count(a.begin(), a.end(), '#');
    int nb = count(b.begin(), b.end(), '#');
    vector<string> ans(7);

    auto print = [&]() -> void {
        cout << "Yes\n";
        for (auto i : ans) {
            for (auto c : i) {
                cout << c;
            }
            cout << '\n';
        }
    };

    if (na == n || nb == n) {
        if (na == nb) {
            for (auto &i : ans)
                i = a;
            print();
            return;
        } else {
            cout << "No\n";
            return;
        }
    }
    ans[0] = a;
    ans[6] = b;
    for (int i = 0; i < n; ++i) {
        ans[1].push_back(ans[0][i] == '#' ? '.' : '#');
        ans[5].push_back(ans[6][i] == '#' ? '.' : '#');
    }
    auto work = [&](int x, int d) -> int {
        int pos = -1;
        ans[d] = string(n, '.');
        for (int i = 0, ok = true; i < n && ok; ++i) {
            if (i > 0) {
                if (ans[x][i - 1] == '#' && ans[x][i] == '.') {
                    ok = false;
                    pos = i;
                    ans[d][i] = '#';
                }
            }
            if (i + 1 < n) {
                if (ans[x][i + 1] == '#' && ans[x][i] == '.') {
                    ok = false;
                    pos = i;
                    ans[d][i] = '#';
                }
            }
        }
        return pos;
    };
    int pos1 = work(1, 2);
    int pos2 = work(5, 4);
    ans[3] = string(n, '.');
    bool ok = false;
    for (int i = min(pos1, pos2) + 1; i < max(pos1, pos2); ++i) {
        ans[3][i] = '#';
        ok = true;
    }
    if (!ok) {
        ans[3][pos1] = '#';
    }
    print();
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 10ms
memory: 3616kb

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: 14ms
memory: 3612kb

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 14ms
memory: 3704kb

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: 15ms
memory: 3864kb

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.