QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#757989#9621. 连方Bicycle_23#AC ✓17ms4600kbC++232.1kb2024-11-17 15:00:552024-11-17 15:00:56

Judging History

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

  • [2024-11-17 15:00:56]
  • 评测
  • 测评结果:AC
  • 用时:17ms
  • 内存:4600kb
  • [2024-11-17 15:00:55]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

constexpr int maxn = 2e5 + 5;
constexpr int mod = 998244353, g = 3;
int n;

void solve()
{
    cin >> n;
    string s[8];
    cin >> s[1] >> s[7];
    if (s[1] == s[7])
    {
        bool flag = 1;
        for (int i = 0; i < n; i++) if (s[1][i] == '.') {flag = 0; break;}
        if (flag) {cout << "YES" << endl; for (int i = 1; i <= 7; i++) cout << s[1] << endl; return;}
    }
    if (s[1] != s[7]) {
        bool flag = 1;
        for (int i = 0; i < n; i++) if (s[1][i] == '.') {flag = 0; break;}
        if (flag) {cout << "NO" << endl; return;}
        flag = 1;
        for (int i = 0; i < n; i++) if (s[7][i] == '.') {flag = 0; break;}
        if (flag) {cout << "NO" << endl; return;}
    }

    s[1] = ' ' + s[1] + ' ';
    s[7] = ' ' + s[7] + ' ';
    for (int i = 1; i <= n; i++)
        if (s[1][i] == '.') s[2] += '#';
        else s[2] += '.';
    for (int i = 1; i <= n; i++)
        if (s[7][i] == '.') s[6] += '#';
        else s[6] += '.';
    s[2] = ' ' + s[2] + ' ';
    s[6] = ' ' + s[6] + ' ';


    for (int i = 0; i < n; i++)
    {
        s[3] += '.';
        s[4] += '.';
        s[5] += '.';
    }
    s[3] = ' ' + s[3] + ' ';
    s[4] = ' ' + s[4] + ' ';
    s[5] = ' ' + s[5] + ' ';
    int idx, idy;
    for (int i = 1; i <= n; i++)
    {
        if (s[2][i] == '.' && (s[2][i - 1] == '#' || s[2][i + 1] == '#')) {s[3][i] = '#'; idx = i; break;}
    }
    for (int i = 1; i <= n; i++)
    {
        if (s[6][i] == '.' && (s[6][i - 1] == '#' || s[6][i + 1] == '#')) {s[5][i] = '#'; idy = i; break;}
    }
    if (idx > idy) swap(idx, idy);
    if (idx + 1 >= idy) s[4][idx] = '#';
    else for (int i = idx + 1; i < idy; i++) s[4][i] = '#';
    cout << "YES" << endl;
    for (int i = 1; i < 8; i++) {for (int j = 1; j <= n; j++)cout << s[i][j]; cout << endl;}
}

signed main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(0);
    int _ = 1;
    cin >> _;
    while (_--) solve();
    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 12ms
memory: 3712kb

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

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 15ms
memory: 4436kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 11ms
memory: 4600kb

input:

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

output:

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

result:

ok Correct.