QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#741814#9621. 连方SkySummerAC ✓7ms4176kbC++202.3kb2024-11-13 15:16:552024-11-13 15:16:56

Judging History

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

  • [2024-11-13 15:16:56]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:4176kb
  • [2024-11-13 15:16:55]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define de(a) cout << #a << " = " << a << "\n"
#define deg(a) cout << #a << " = " << a << " "
const long double pi = acosl(-1);
constexpr long double eps = 1e-12;
constexpr long long inf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 998244353;
constexpr int N = 1e6 + 10;
constexpr int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
unsigned long long a[N], b[N];

void solve() {
    int n;
    cin >> n;
    string s1, s7;
    cin >> s1 >> s7;

    if (s1 == string(n, '#') && s7 == string(n, '#')) {
        cout << "Yes\n";
        cout << s1 << "\n";
        cout << s1 << "\n";
        cout << s1 << "\n";
        cout << s1 << "\n";
        cout << s1 << "\n";
        cout << s1 << "\n";
        cout << s1 << "\n";
        return;
    } else if (s1 == string(n, '#') || s7 == string(n, '#')) {
        cout << "No\n";
        return;
    }

    string s2, s6;
    for (int i = 0; i < n; i++) {
        s2 += (s1[i] == '#' ? '.' : '#');
        s6 += (s7[i] == '#' ? '.' : '#');
    }

    string s3(n, '.'), s4(n, '.'), s5(n, '.');
    int l, r;
    for (int i = 0; i + 1 < n; i++) {
        if (s2[i] != s2[i + 1]) {
            if (s2[i] == '#') {
                s3[i + 1] = '#';
                l = i + 1;
            } else {
                s3[i] = '#';
                l = i;
            }
            break;
        }
    }
    for (int i = 0; i + 1 < n; i++) {
        if (s6[i] != s6[i + 1]) {
            if (s6[i] == '#') {
                s5[i + 1] = '#';
                r = i + 1;
            } else {
                s5[i] = '#';
                r = i;
            }
            break;
        }
    }

    if (l > r) {
        swap(l, r);
    }

    if (r - l <= 1) {
        s4 = s3;
    } else {
        for (int i = l + 1; i <= r - 1; i++) {
            s4[i] = '#';
        }
    }

    cout << "Yes\n";
    cout << s1 << "\n";
    cout << s2 << "\n";
    cout << s3 << "\n";
    cout << s4 << "\n";
    cout << s5 << "\n";
    cout << s6 << "\n";
    cout << s7 << "\n";
}

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

    int T = 1;
    cin >> T, cin.get();
    while (T--) {
        solve();
    }

    return 0;
}

详细

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 0ms
memory: 4176kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 0ms
memory: 4140kb

input:

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

output:

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

result:

ok Correct.