QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#741721#9621. 连方ticking_away#AC ✓14ms4752kbC++203.1kb2024-11-13 15:04:472024-11-13 15:04:49

Judging History

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

  • [2024-11-13 15:04:49]
  • 评测
  • 测评结果:AC
  • 用时:14ms
  • 内存:4752kb
  • [2024-11-13 15:04:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ull = unsigned long long;
using ll = long long;
#define endl '\n'
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int maxn = 2e5 + 10;
const int mod = 1000000007;
#define inl inline
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define ford(i, a, b) for (int i = a; i >= b; i--)
#define forall(i, a) for (auto &i : a)

/**
   ____         ___ _____
  / ___| _   _ / _ \___ /
  \___ \| | | | | | ||_ \
   ___) | |_| | |_| |__) |
  |____/ \__, |\___/____/
         |___/
*/
istream &operator>>(istream &in, vector<int> &v)
{
    for (auto &i : v)
        in >> i;
    return in;
}
ostream &operator<<(ostream &out, vector<int> &v)
{
    for (auto &i : v)
        out << i << " ";
    return out;
}
bool _output = 1;

char a[8][maxn];
void solve()
{
    int n;
    cin >> n;
    string s1, s2;
    // cin>>a>>b ;
    cin >> s1 >> s2;
    int f1 = s1.find('.') == string::npos;
    int f2 = s2.find('.') == string::npos;
    // cout << f1 << " " << f2 << endl;
    if (f1 + f2 == 2)
    {
        cout << "Yes" << endl;
        cout << s1 << endl;
        fr(i, 2, 6)
        {
            fr(j, 1, n)
                    cout
                << "#";
            cout << endl;
        }
        cout << s2 << endl;
        return;
    }
    else if (f1 + f2 == 1)
    {
        cout << "No" << endl;
        return;
    }
    fr(i, 1, 7) fr(j, 1, n) a[i][j] = '.';
    fr(i, 1, n) a[1][i] = s1[i - 1];
    fr(i, 1, n) a[7][i] = s2[i - 1];

    fr(i, 1, n)
    {
        if (a[1][i] == '.')
            a[2][i] = '#';
        else
            a[2][i] = '.';
    }

    fr(i, 1, n)
    {
        if (a[7][i] == '.')
            a[6][i] = '#';
        else
            a[6][i] = '.';
    }

    int l1 = -1, l2 = -1;
    fr(i, 1, n) if (a[2][i] == '.')
    {
        if (i > 1 && a[2][i - 1] == '#')
        {
            l1 = i;
            break;
        }
        if (i < n && a[2][i + 1] == '#')
        {
            l1 = i;
            break;
        }
    }

    fr(i, 1, n) if (a[6][i] == '.')
    {
        if (i > 1 && a[6][i - 1] == '#')
        {
            l2 = i;
            break;
        }
        if (i < n && a[6][i + 1] == '#')
        {
            l2 = i;
            break;
        }
    }

    // cout << l1 << " " << l2 << endl;
    a[3][l1] = '#';
    a[5][l2] = '#';
    if (l1 > l2)
        swap(l1, l2);
    if (abs(l1 - l2) <= 1)
    {
        a[4][l1] = '#';
    }
    else
    {
        for (int i = 3; i <= 5; i++)
        {
            fr(j, 1, n)
            {
                if (i == 4 && j > l1 && j < l2)
                {
                    a[i][j] = '#';
                }
            }
        }
    }

    cout << "Yes" << endl;
    fr(i, 1, 7)
    {
        fr(j, 1, n) cout << a[i][j];
        cout << endl;
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    if (_output)
        cin >> _;
    while (_--)
        solve();
    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 8ms
memory: 3660kb

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: 14ms
memory: 3708kb

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 7ms
memory: 4752kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 7ms
memory: 4748kb

input:

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

output:

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

result:

ok Correct.