QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#751510#9621. 连方LittleXi#AC ✓9ms4092kbC++201.8kb2024-11-15 19:12:312024-11-15 19:12:38

Judging History

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

  • [2024-11-15 19:12:38]
  • 评测
  • 测评结果:AC
  • 用时:9ms
  • 内存:4092kb
  • [2024-11-15 19:12:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rof(i,a,b) for(int i=(a);i>=(b);i--)
#define wln putchar('\n')
const int N=200005;
int n;
char s1[N],s2[N],ans[7][N];
char inv(char ch){return ch=='.'?'#':'.';}
void Main()
{
    scanf("%d",&n);
    scanf("%s",s1);
    scanf("%s",s2);
    int cnt1=0,p1=-1,cnt2=0,p2=-1;
    For(i,0,n-1)
    {
        cnt1+=s1[i]=='#';
        if(i>0&&s1[i]=='#'&&s1[i-1]=='.')p1=i;
        if(i<n-1&&s1[i]=='#'&&s1[i+1]=='.')p1=i;
    }
    For(i,0,n-1)
    {
        cnt2+=s2[i]=='#';
        if(i>0&&s2[i]=='#'&&s2[i-1]=='.')p2=i;
        if(i<n-1&&s2[i]=='#'&&s2[i+1]=='.')p2=i;
    }
    if(cnt1==n&&cnt2==n)
    {
        printf("Yes\n");
        For(i,0,6)printf("%s\n",s1);
        return;
    }
    if(cnt1==0)
    {
        printf("Yes\n");
        For(i,0,4)printf("%s\n",s1);
        For(i,0,n-1)putchar(inv(s2[i])); wln;
        For(i,0,n-1)putchar(s2[i]); wln;
        return;
    }
    if(cnt2==0)
    {
        printf("Yes\n");
        For(i,0,n-1)putchar(s1[i]); wln;
        For(i,0,n-1)putchar(inv(s1[i])); wln;
        For(i,0,4)printf("%s\n",s2);
        return;
    }
    if(cnt1==n||cnt2==n)
    {
        printf("No\n");
        return;
    }
    printf("Yes\n");
    // printf("p1=%d,p2=%d\n",p1,p2);
    int x=min(p1,p2),y=max(p1,p2);
    For(i,0,n-1)putchar(s1[i]); wln;
    For(i,0,n-1)putchar(inv(s1[i])); wln;
    For(i,0,n-1)putchar(i==p1?'#':'.'); wln;
    if(y-x>1)
    {
        For(i,0,n-1)putchar(i>x&&i<y?'#':'.'); wln;
    }
    else 
    {
        For(i,0,n-1)putchar(i==p1?'#':'.'); wln;
    }
    For(i,0,n-1)putchar(i==p2?'#':'.'); wln;
    For(i,0,n-1)putchar(inv(s2[i])); wln;
    For(i,0,n-1)putchar(s2[i]); wln;
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)Main();
}

详细

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 8ms
memory: 3848kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 9ms
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: 9ms
memory: 3908kb

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.