QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#739201#9621. 连方chenjiaqiyAC ✓20ms3860kbC++202.7kb2024-11-12 21:09:182024-11-12 21:09:20

Judging History

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

  • [2024-11-12 21:09:20]
  • 评测
  • 测评结果:AC
  • 用时:20ms
  • 内存:3860kb
  • [2024-11-12 21:09:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
#define double long double
#define endl '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define x first
#define y second
#define debug(_x) cout << #_x << '=' << _x << endl
typedef pair<int, int> PII;
using i64 = long long;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

void solve()
{
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == '#')
            cnt1++;
        if (b[i] == '#')
            cnt2++;
    }
    if (cnt1 == n && cnt2 == n)
    {
        cout << "YES\n";
        for (int i = 1; i <= 7; i++)
        {
            for (int j = 1; j <= n; j++)
                cout << '#';
            cout << endl;
        }
        return;
    }
    else if (cnt1 == n || cnt2 == n)
    {
        cout << "NO\n";
        return;
    }
    int pos1 = -1, pos2 = -1;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == '#' && ((i - 1 >= 0 && a[i - 1] == '.') || (i + 1 < n && a[i + 1] == '.')))
        {
            pos1 = i;
            break;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (b[i] == '#' && ((i - 1 >= 0 && b[i - 1] == '.') || (i + 1 < n && b[i + 1] == '.')))
        {
            pos2 = i;
            break;
        }
    }
    cout << "YES\n";
    cout << a << endl;
    for (int i = 0; i < n; i++)
        cout << char('.' + '#' - a[i]);
    cout << endl;
    for (int i = 1; i <= n; i++)
    {
        if (i != pos1 + 1)
            cout << '.';
        else
            cout << '#';
    }
    cout << endl;
    int start = min(pos1, pos2) + 1, end = max(pos1, pos2) + 1;
    if (start == end || start + 1 == end)
    {
        for (int i = 1; i <= end - 1; i++)
            cout << '.';
        cout << '#';
        for (int i = end + 1; i <= n; i++)
            cout << '.';
    }
    else
    {
        for (int i = 1; i <= start; i++)
            cout << '.';
        for (int i = start + 1; i < end; i++)
            cout << '#';
        for (int i = end; i <= n; i++)
            cout << '.';
    }
    cout << endl;
    for (int i = 1; i <= n; i++)
    {
        if (i != pos2 + 1)
            cout << '.';
        else
            cout << '#';
    }
    cout << endl;
    for (int i = 0; i < n; i++)
        cout << (char)('.' + '#' - b[i]);
    cout << endl;
    cout << b << endl;
}

int main()
{
    /*ios::sync_with_stdio(false);
    cin.tie(nullptr);*/
    int _ = 1;
    cin >> _;

    while (_--)
        solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3708kb

input:

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

output:

YES
#..#
.##.
#...
.#..
.#..
#..#
.##.
YES
##.#.
..#.#
.#...
.#...
.#...
#.#..
.#.##
NO
YES
.######.######.####.#.#####
#......#......#....#.#.....
.#.........................
.#.........................
.#.........................
#....###....##.#######.....
.####...####..#.......#####
YES
########...

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 20ms
memory: 3816kb

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

input:

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

output:

YES
#######.#######.#########################
.......#.......#.........................
......#..................................
.......########..........................
...............#.........................
................#...#.......#............
################.###.#######.############
YE...

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 19ms
memory: 3860kb

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: 15ms
memory: 3500kb

input:

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

output:

NO
YES
###...
...###
..#...
..#...
.#....
..##.#
##..#.
YES
.#.######
#.#......
.#.......
.#.......
#........
.#.##....
#.#..####
YES
######.##########################################
......#..........................................
.....#...........................................
......#............

result:

ok Correct.

Test #6:

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

input:

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

output:

YES
###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....

result:

ok Correct.

Test #7:

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

input:

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

output:

YES
##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........

result:

ok Correct.