QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#739094#9621. 连方susanzhishen#AC ✓20ms4676kbC++202.7kb2024-11-12 20:49:542024-11-12 20:50:24

Judging History

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

  • [2024-11-12 20:50:24]
  • 评测
  • 测评结果:AC
  • 用时:20ms
  • 内存:4676kb
  • [2024-11-12 20:49:54]
  • 提交

answer

#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

const int N = 1e5 + 100;

int n;
char a[5][N], b[5][N];

int tkl(char c[4][N]) {
    if(c[0][1] == '#') for(int i = 1; i <= n; ++i)
        if(c[0][i] == '.') {
            c[1][i] = '#';
            break;
        }
    for(int i = 1; i < n; ++i) {
        if(c[0][i] == '.' && c[0][i + 1] == '#')
            c[1][i] = '#';
    }
    for(int i = 1; i < n; ++i) {
        if(c[1][i] == '#' && c[1][i + 1] == '#') {
            int res = c[2][i] == '#' ? i : i + 1;
            c[2][i] = c[2][i + 1] = '.';
            return res;
        }
    }
    // for(int i = 1; i <= n; ++i) {
    //     if(c[1][i] == '#') {
    //         if(i < n && c[1][i + 1] == '#') {
    //             if(c[3][i] == '#') c[2][i - 1] = '#';
    //             else c[2][i + 1 + 1] = '#';
    //             ++i;
    //         }
    //         else {
    //             if(c[3][i] == '#') c[2][i] = '#';
    //             else if(i > 1) c[2][i - 1] = '#';
    //             else c[2][i + 1] = '#';
    //         }
    //     }
    // }
    return 0;
}

void slv() {
    scanf("%d%s%s", &n, a[0] + 1, b[0] + 1);
    bool alla = true, allb = true;
    for(int i = 1; i <= n; ++i)
        if(a[0][i] == '.') alla = false;
    for(int i = 1; i <= n; ++i)
        if(b[0][i] == '.') allb = false;
    if(alla && allb) {
        printf("Yes\n");
        for(int i = 1; i <= 7; ++i)
            printf("%s\n", a[0] + 1);
    }
    else if(alla || allb) {
        printf("No\n");
    }
    else {
        printf("Yes\n");
        memset(a[1], '.', sizeof(*(a[1])) * (n + 10));
        // memset(a[2], '.', sizeof(*(a[2])) * (n + 10));
        memset(b[1], '.', sizeof(*(b[1])) * (n + 10));
        // memset(b[2], '.', sizeof(*(b[2])) * (n + 10));
        for(int i = 1; i <= n; ++i)
            a[3][i] = b[3][i] = (i & 1) ? '#' : '.';
        for(int i = 1; i <= n; ++i)
            a[2][i] = b[2][i] = (i & 1) ? '.' : '#';
        int ap = tkl(a);
        int bp = tkl(b);
cerr << ap << ' ' << bp << endl;
        if(ap == bp) a[3][ap] = b[3][ap] = '#';
        a[1][n + 1] = a[2][n + 1] = a[3][n + 1] = '\0';
        b[1][n + 1] = b[2][n + 1] = b[3][n + 1] = '\0';
        for(int i = 0; i < 4; ++i) printf("%s\n", a[i] + 1);
        for(int i = 2; i >= 0; --i) printf("%s\n", b[i] + 1);
    }
}


int main() {
    int t;
    scanf("%d", &t);
    while(t--) {
        slv();
    }



    return 0;
}


/*
4
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 2ms
memory: 4628kb

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.