QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#757958#9621. 连方electricstick#AC ✓7ms2200kbC++201.8kb2024-11-17 14:51:542024-11-17 14:51:55

Judging History

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

  • [2024-11-17 14:51:55]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:2200kb
  • [2024-11-17 14:51:54]
  • 提交

answer

#include<cstdio>
const int N = 1e5 + 10;
char s[10][N];
int main() {
    int t; scanf("%d", &t);
    while(t--) {
        int n; scanf("%d", &n);
        scanf(" %s", s[1] + 1);
        scanf(" %s", s[7] + 1);
        int l1 = -1, r1 = -1, cnt1 = 0, l2 = -1, r2 = -1, cnt2 = 0;
        for(int i = 1; i <= n; i++) {
            if(s[1][i] == '#') {
                if(i == 1 || s[1][i - 1] != '#') l1 = i, ++cnt1;
                if(i == n || s[1][i + 1] != '#') r1 = i;
            }
            if(s[7][i] == '#') {
                if(i == 1 || s[7][i - 1] != '#') l2 = i, ++cnt2;
                if(i == n || s[7][i + 1] != '#') r2 = i;
            }
        }
        if(cnt1 == 1 && cnt2 == 1 && l1 == l2 && r1 == r2) {
            puts("Yes");
            for(int i = 1; i <= 7; i++) {
                puts(s[1] + 1);
            }
            continue;
        }
        for(int i = 1; i <= n; i++) {
            s[2][i] = s[1][i] == '.'? '#': '.';
            s[6][i] = s[7][i] == '.'? '#': '.';
        }
        int p = -1, q = -1;
        for(int i = 1; i <= n; i++) {
            if(i > 1 && s[2][i] == '.' && s[2][i - 1] == '#') p = i;
            if(i < n && s[2][i] == '.' && s[2][i + 1] == '#') p = i;
            if(i > 1 && s[6][i] == '.' && s[6][i - 1] == '#') q = i;
            if(i < n && s[6][i] == '.' && s[6][i + 1] == '#') q = i;
            s[3][i] = s[4][i] = s[5][i] = '.';
        }
        if(p == -1 || q == -1) {
            puts("No");
            continue;
        }
        puts("Yes");
        s[3][p] = '#'; s[5][q] = '#';
        if(p > q) p ^= q ^= p ^= q;
        if(p == q) s[4][p] = '#';
        else if(p + 1 == q) s[4][p] = '#';
        else {
            for(int i = p + 1; i < q; i++) s[4][i] = '#';
        }
        for(int i = 1; i <= 7; i++) {
            s[i][n + 1] = 0;
            puts(s[i] + 1);
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 6ms
memory: 1428kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 6ms
memory: 1620kb

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

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.