QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#764157#9621. 连方DarwinA66AC ✓40ms4540kbC++203.0kb2024-11-20 01:44:532024-11-20 01:44:55

Judging History

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

  • [2024-11-20 01:44:55]
  • 评测
  • 测评结果:AC
  • 用时:40ms
  • 内存:4540kb
  • [2024-11-20 01:44:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=100010;
char str1[N],str2[N],str3[N],str4[N],str5[N],str6[N],str7[N];
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int n;
        scanf("%d",&n);
        getchar();
        scanf("%s",str1);
        getchar();
        scanf("%s",str7);
        int cnt_up_dot=0;
        int cnt_down_dot=0;
        for(int i=0;i<n;i++)
        {
            if(str1[i]=='#')str2[i]='.';
            else 
            {
                cnt_up_dot++;
                str2[i]='#';
            }
            if(str7[i]=='#')str6[i]='.';
            else
            {
                cnt_down_dot++;
                str6[i]='#';
            }
        }
        int curr_up=114514;
        int curr_down=114514;
        for(int i=0;i+1<n;i++)
        {
            if(str2[i]=='.'&&str2[i+1]=='#'&&curr_up==114514)
            {
                curr_up=i;
            }
            else if(str2[i]=='#'&&str2[i+1]=='.'&&curr_up==114514)
            {
                curr_up=i+1;
            }

            if(str6[i]=='.'&&str6[i+1]=='#'&&curr_down==114514)
            {
                curr_down=i;
            }
            else if(str6[i]=='#'&&str6[i+1]=='.'&&curr_down==114514)
            {
                curr_down=i+1;
            }
        }
        for(int i=0;i<n;i++)
        {
            if(i==curr_up)str3[i]='#';
            else str3[i]='.';

            if(i==curr_down)str5[i]='#';
            else str5[i]='.';
        }
        if(fabs(curr_up-curr_down)<=1)
        {
            for(int i=0;i<n;i++)
            {
                if(i==curr_down)str4[i]='#';
                else str4[i]='.';
            }
        }
        else 
        {
            for(int i=0;i<n;i++)
            {
                if((min(curr_up,curr_down)<i)&&(i<max(curr_up,curr_down)))str4[i]='#';
                else str4[i]='.';
            }
        }
        if(cnt_down_dot==0 && cnt_up_dot==0)
        {
            printf("Yes\n");
            for(int i=1;i<=7;i++)
            {
                for(int j=1;j<=n;j++)
                {
                    printf("#");
                }
                printf("\n");
            }
        }
        else if(cnt_down_dot==0 || cnt_up_dot==0)
        {
            printf("No\n");
        }
        else
        {
            printf("Yes\n");
            for(int i=0;i<n;i++)printf("%c",str1[i]);
            printf("\n");
            for(int i=0;i<n;i++)printf("%c",str2[i]);
            printf("\n");
            for(int i=0;i<n;i++)printf("%c",str3[i]);
            printf("\n");
            for(int i=0;i<n;i++)printf("%c",str4[i]);
            printf("\n");
            for(int i=0;i<n;i++)printf("%c",str5[i]);
            printf("\n");
            for(int i=0;i<n;i++)printf("%c",str6[i]);
            printf("\n");
            for(int i=0;i<n;i++)printf("%c",str7[i]);
            printf("\n");
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 37ms
memory: 3908kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 34ms
memory: 3896kb

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

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 38ms
memory: 4540kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 34ms
memory: 4528kb

input:

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

output:

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

result:

ok Correct.