QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#759280#9621. 连方Ail_ijyqAC ✓8ms4420kbC++202.5kb2024-11-17 23:58:172024-11-17 23:58:17

Judging History

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

  • [2024-11-17 23:58:17]
  • 评测
  • 测评结果:AC
  • 用时:8ms
  • 内存:4420kb
  • [2024-11-17 23:58:17]
  • 提交

answer

#include<bits/stdc++.h>

#define endl "\n"
// #define int long long

using namespace std;

using i64 = long long;
using u64 = unsigned long long;

constexpr int N = 5e5 + 10, M = 20;
constexpr int P = 1e9 + 7;
constexpr int INF = 1e9;

void solve() {
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    auto oppose = [&](char c) {
        if (c == '#') {
            return '.';
        } else {
            return '#';
        }
    };
    if (s1.find('.') == string::npos && s2.find('.') == string::npos) {
        cout << "Yes\n";
        for (int i = 0; i < 7; i++) {
            cout << s1 << endl;
        }
    } else if (s1.find('.') == string::npos || s2.find('.') == string::npos) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        vector<string> ans(7);
        for (auto &_ : ans) {
            _ = string(n, '.');
        }
        ans[0] = s1;
        ans[6] = s2;
        for (int i = 0; i < n; i++) {
            ans[1][i] = oppose(ans[0][i]);
        }
        for (int i = 0; i < n; i++) {
            ans[5][i] = oppose(ans[6][i]);
        }
        for (int i = 0; i < n - 1; i++) {
            if (ans[1][i] != ans[1][i + 1]) {
                if (ans[1][i] == '.') {
                    ans[2][i] = '#';
                } else {
                    ans[2][i + 1] = '#';
                }
                break;
            }
        }
        for (int i = 0; i < n - 1; i++) {
            if (ans[5][i] != ans[5][i + 1]) {
                if (ans[5][i] == '.') {
                    ans[4][i] = '#';
                } else {
                    ans[4][i + 1] = '#';
                }
                break;
            }
        }
        for (int i = 0; i < n; i++) {
            if (ans[2][i] == ans[4][i] && ans[2][i] == '#') {
                ans[3][i] = '#';
                goto out;
            }
        }
        for (int i = 0; i < n - 1; i++) {
            if (ans[2][i] != ans[4][i] && ans[2][i + 1] != ans[4][i + 1]) {
                ans[3][i] = '#';
                goto out;
            }
        }
        for (int i = 0; i < n; i++) {
            if (ans[2][i] == ans[4][i] && ans[2][i] == '.') {
                ans[3][i] = '#';
            }
        }
out:
        for (const auto &_ : ans) {
            cout << _ << endl;
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T;
    cin >> T;
    while (T--) {
        solve();
    }
}

詳細信息

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: 3ms
memory: 3728kb

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: 8ms
memory: 3696kb

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.