QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789267#9621. 连方Texcavator#AC ✓17ms4424kbC++233.2kb2024-11-27 19:42:322024-11-27 19:42:33

Judging History

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

  • [2024-11-27 19:42:33]
  • 评测
  • 测评结果:AC
  • 用时:17ms
  • 内存:4424kb
  • [2024-11-27 19:42:32]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

void solve()
{
    int n; cin >> n;
    string s1, s2; cin >> s1 >> s2;
    s1 = " " + s1, s2 = " " + s2;

    int pos = 0;
    int cnt1 = 0, cnt2 = 0;
    for (int i = 1; i <= n; i ++ )
    {
        if (s1[i] == '#' && pos == 0) pos = i;
        if (s1[i] == '.') cnt1 ++ ;
        if (s2[i] == '.') cnt2 ++ ;
    }
    if (cnt1 == n || cnt2 == n)
    {
        cout << "Yes\n";
        for (int i = 1; i <= n; i ++ ) cout << s1[i];
        cout << '\n';
        for (int i = 2; i <= 6; i ++ )
        {
            for (int j = 1; j <= n; j ++ )
            {
                cout << '.';
            }
            cout << '\n';
        }
        for (int i = 1; i <= n; i ++ ) cout << s2[i];
        cout << '\n';
        return;
    }
    if (cnt1 == 0 && cnt2 == 0)
    {
        cout << "Yes\n";
        for (int i = 1; i <= 7; i ++ )
        {
            for (int j = 1; j <= n; j ++ )
            {
                cout << '#';
            }
            cout << '\n';
        }
        return;
    }
    if (cnt1 != 0 && cnt2 == 0)
    {
        cout << "No\n";
        return;
    }
    else if (cnt1 == 0 && cnt2 != 0)
    {
        cout << "No\n";
        return;
    }

    vector<vector<char>> g(8, vector<char>(n + 1));

    for (int i = 1; i <= n; i ++ ) g[1][i] = s1[i];
    for (int i = 1; i <= n; i ++ ) g[7][i] = s2[i];

    // 2
    for (int i = 1; i <= n; i ++ )
    {
        if (i < pos) g[2][i] = '.';
        else
        {
            if (s1[i] == '.') g[2][i] = '#';
            else g[2][i] = '.';
        }
    }
    auto check = [&]()
    {
        int cnt = 0;
        for (int i = 1; i <= n; i ++ )
        {
            if (g[2][i] == '.') cnt ++ ;
        }
        if (cnt == n) return true;
        else return false;
    };
    if (check())
    {
        for (int i = 1; i <= n; i ++ ) g[2][i] = g[1][i];
    }

    // 3
    if (g[2][1] == '.' && g[2][2] == '#')
    {
        g[3][1] = '#';
        for (int i = 2; i <= n; i ++ ) g[3][i] = '.';
    }
    else
    {
        g[3][1] = '.';
        for (int i = 2; i <= n; i ++ )
        {
            if (g[2][i] == '#')
            {
                pos = i;
                break;
            }
            g[3][i] = '#';
        }
        for (int i = pos; i <= n; i ++ ) g[3][i] = '.';
    }

    // 4
    g[4][1] = '#';
    for (int i = 2; i <= n; i ++ ) g[4][i] = '.';

    // 5
    g[5][1] = '.';
    for (int i = 2; i <= n; i ++ ) g[5][i] = '#';

    // 6
    for (int i = 1; i <= n; i ++ )
    {
        if (s2[i] == '.')
        {
            g[6][i] = '#';
            g[5][i] = '.';
            if (i == 2) g[5][1] = '#';
        }
        else g[6][i] = '.';
    }
    if (g[6][2] == '#') g[6][1] = '.';

    cout << "Yes\n";
    for (int i = 1; i <= 7; i ++ )
    {
        for (int j = 1; j <= n; j ++ )
        {
            cout << g[i][j];
        }
        cout << '\n';
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int t = 1;
    cin >> t;
    while (t -- )
    {
        solve();
    }
}

详细

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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: 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: 17ms
memory: 3628kb

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

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.