QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#789900#9621. 连方goukTL 0ms3604kbC++202.2kb2024-11-27 22:35:432024-11-27 22:35:44

Judging History

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

  • [2024-11-27 22:35:44]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3604kb
  • [2024-11-27 22:35:43]
  • 提交

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] = '#';
                }
            } else 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;
    if (pos1 == -1 || pos2 == -1) {
        vector<vector<int>> mle;
        while (true) {
            mle.push_back(vector<int>(1000000));
        }
    }
    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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: -100
Time Limit Exceeded

input:

10000
6
.#..##
..#...
5
#..#.
##...
6
.###.#
...###
17
.####..#######..#
###########.#####
6
..##.#
#.##.#
25
#.##.##############.####.
####################.##.#
9
##.#..##.
##..#####
6
.###.#
##.###
6
###..#
#.####
25
#####################.#.#
######.##################
6
.#.###
.##..#
6
..####
#......

output:


result: