QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#789578#9621. 连方Hojstyer#AC ✓10ms4136kbC++203.0kb2024-11-27 20:58:082024-11-27 20:58:09

Judging History

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

  • [2024-11-27 20:58:09]
  • 评测
  • 测评结果:AC
  • 用时:10ms
  • 内存:4136kb
  • [2024-11-27 20:58:08]
  • 提交

answer

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

typedef long long ll;

void solve()
{
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;

    int cnt = 0;
    for (int i = 0; i < n; ++i)
        cnt += (a[i] == '#');

    if (a == b && cnt == n)
    {
        cout << "Yes\n";
        for (int i = 0; i < 7; ++i)
            cout << a << '\n';
        return;
    }
    else
    {
        int p1 = -1, p2 = -1;
        for (int i = 0; i < n; ++i)
        {
            if (a[i] == '.')
                p1 = i;
            if (b[i] == '.')
                p2 = i;
        }

        if (p1 == -1 || p2 == -1)
            cout << "No\n";
        else
        {
            cout << "Yes\n";
            cout << a << "\n";
            string res;
            for (int i = 0; i < n; ++i)
                if (a[i] == '.')
                    res += '#';
                else
                    res += '.';
            cout << res << '\n';
            res.clear();

            for (int i = 1; i < n; ++i)
            {
                if (a[i] == '#' && a[i - 1] == '.')
                    p1 = i;
                if (b[i] == '#' && b[i - 1] == '.')
                    p2 = i;
            }
            for (int i = 0; i < n - 1; ++i)
            {
                if (a[i] == '#' && a[i + 1] == '.')
                    p1 = i;
                if (b[i] == '#' && b[i + 1] == '.')
                    p2 = i;
            }

            for (int i = 0; i < n; ++i)
                if (p1 == i)
                    res += '#';
                else
                    res += '.';
            cout << res << '\n';
            res.clear();

            if (abs(p1 - p2) <= 1)
            {
                for (int i = 0; i < n; ++i)
                    if (p1 == i)
                        res += '#';
                    else
                        res += '.';
                cout << res << '\n';
                res.clear();
            }
            else
            {
                for (int i = 0; i <= min(p1, p2); ++i)
                    res += '.';
                for (int i = min(p1, p2) + 1; i <= max(p1, p2) - 1; ++i)
                    res += '#';
                for (int i = max(p1, p2); i < n; ++i)
                    res += '.';
                cout << res << "\n";
                res.clear();
            }

            for (int i = 0; i < n; ++i)
                if (p2 == i)
                    res += '#';
                else
                    res += '.';
            cout << res << '\n';
            res.clear();

            for (int i = 0; i < n; ++i)
                if (b[i] == '.')
                    res += '#';
                else
                    res += '.';
            cout << res << '\n';
            res.clear();
            cout << b << "\n";
        }
    }
}

int 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: 3608kb

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 6ms
memory: 3856kb

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: 6ms
memory: 3516kb

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 5ms
memory: 3524kb

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

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

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 9ms
memory: 4136kb

input:

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

output:

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

result:

ok Correct.