QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#740324#9621. 连方KomorebieAC ✓16ms7108kbC++171.6kb2024-11-13 08:56:312024-11-13 08:56:31

Judging History

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

  • [2024-11-13 08:56:31]
  • 评测
  • 测评结果:AC
  • 用时:16ms
  • 内存:7108kb
  • [2024-11-13 08:56:31]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

void solve()
{
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    int cnta = count(a.begin(), a.end(), '#'), cntb = count(b.begin(), b.end(), '#');
    if (cnta == n && cntb == n) {
        cout << "Yes\n";
        for (int i = 0; i < 7; i++) cout << a << "\n";
        return;
    }
    if (cnta == n || cntb == n) {
        cout << "No\n";
        return;
    }
    vector<vector<int>> mp(8, vector<int>(n + 1));
    for (int i = 0; i < n; i++) {
        mp[1][i + 1] = a[i] == '#';
        mp[7][i + 1] = b[i] == '#';
    }
    for (int i = 1; i <= n; i++) {
        mp[2][i] = mp[1][i] != 1;
    }
    for (int i = 1; i <= n; i++) {
        mp[6][i] = mp[7][i] != 1;
    }
    int p, q;
    for (int i = 1; i <= n; i++) {
        if (mp[2][i] != 1 && (mp[2][i - 1] || mp[2][i + 1])) {
            mp[3][i] = 1;
            p = i;
            break;
        }
    }
    for (int i = 1; i <= n; i++) {
        if (mp[6][i] != 1 && (mp[6][i - 1] || mp[6][i + 1])) {
            mp[5][i] = 1;
            q = i;
            break;
        }
    }

    if (p == q || abs(p - q) == 1) {
        mp[4][p] = 1;
    }
    else {
        for (int i = min(p, q) + 1; i <= max(p, q) - 1; i++) {
            mp[4][i] = 1;
        }
    }

    cout << "Yes\n";
    for (int i = 1; i <= 7; i++) {
        for (int j = 1; j <= n; j++) {
            cout << (mp[i][j] ? '#' : '.');
        }
        cout << "\n";
    }
}

int main()
{
    ios::sync_with_stdio(false), cin.tie(0);
    int tt;
    cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

详细

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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: 12ms
memory: 3988kb

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

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: 10ms
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: 9ms
memory: 7076kb

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.