QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#739051#9621. 连方DBsoleil#AC ✓40ms4572kbC++231.3kb2024-11-12 20:42:372024-11-12 20:42:38

Judging History

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

  • [2024-11-12 20:42:38]
  • 评测
  • 测评结果:AC
  • 用时:40ms
  • 内存:4572kb
  • [2024-11-12 20:42:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef double db;

const int N=1e5+5;
int n,m;
char a[10][N];


void input()
{
    scanf("%d",&n);
    for(int i=1;i<=7;i++) for(int j=1;j<=n;j++) a[i][j]='.';
    scanf("%s%s",a[1]+1,a[7]+1);
}

bool check()
{
    int fa=0,fb=0;
    for(int i=1;i<=n;i++) fa|=(a[1][i]=='.');
    for(int i=1;i<=n;i++) fb|=(a[7][i]=='.');
    if(fa!=fb)
    {
        printf("NO\n");
        return 0;
    }
    printf("YES\n");
    if(!fa)
    {
        for(int i=1;i<=7;i++)
        {
            for(int j=1;j<=n;j++) printf("#");
            printf("\n");
        }
        return 0;
    }
    return 1;
}

int findpos(char* s)
{
    for(int i=2;i<=n;i++) if(s[i-1]!=s[i]) return s[i]=='#'?i:i-1;
    return -1;
}

void work()
{
    for(int i=1;i<=n;i++) a[2][i]='#'+'.'-a[1][i],a[6][i]='#'+'.'-a[7][i];
    int p1=findpos(a[1]),p7=findpos(a[7]);
    a[3][p1]=a[5][p7]='#';
    if(abs(p1-p7)<=1) a[4][p1]='#';
    for(int i=min(p1,p7)+1;i<max(p1,p7);i++) a[4][i]='#';
}

void output()
{
    for(int i=1;i<=7;i++)
    {
        for(int j=1;j<=n;j++) printf("%c",a[i][j]);
        printf("\n");
    }
}

void solve()
{
    input();
    if(!check()) return;
    work();
    output();
}

int main()
{
    int T=1;
    scanf("%d",&T);
    while(T--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 35ms
memory: 3912kb

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

input:

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

output:

YES
#######.#######.#########################
.......#.......#.........................
......#..................................
.......########..........................
...............#.........................
................#...#.......#............
################.###.#######.############
YE...

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 32ms
memory: 3880kb

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

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 31ms
memory: 4572kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 31ms
memory: 4524kb

input:

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

output:

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

result:

ok Correct.