QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#736847#9621. 连方hezlik#AC ✓12ms4332kbC++202.1kb2024-11-12 13:39:502024-11-12 13:39:51

Judging History

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

  • [2024-11-12 13:39:51]
  • 评测
  • 测评结果:AC
  • 用时:12ms
  • 内存:4332kb
  • [2024-11-12 13:39:50]
  • 提交

answer

#include <bits/stdc++.h>

typedef long long int64;

int n;
std::string a,b;

void work(){
  std::cin>>n>>a>>b;
  std::vector<int> p,q;
  for (int i=0;i<n;++i){
    if (a[i]=='.') p.push_back(i);
    if (b[i]=='.') q.push_back(i);
  }
  if (p.empty()&&q.empty()){
    std::cout<<"Yes\n";
    for (int i=0;i<7;++i){
      for (int j=0;j<n;++j)
        std::cout<<'#';
      std::cout<<'\n';
    }
    return;
  }
  if (p.empty()||q.empty()){
    std::cout<<"No\n";
    return;
  }
  std::cout<<"Yes\n";
  if ((int)p.size()==n){
    for (int i=0;i<5;++i){
      for (int j=0;j<n;++j)
        std::cout<<'.';
      std::cout<<'\n';
    }
    for (int i=0;i<n;++i)
      std::cout<<(b[i]=='.'?'#':'.');
    std::cout<<b<<'\n';
    return;
  }
  if ((int)q.size()==n){
    std::cout<<a<<'\n';
    for (int i=0;i<n;++i)
      std::cout<<(a[i]=='.'?'#':'.');
    for (int i=0;i<5;++i){
      for (int j=0;j<n;++j)
        std::cout<<'.';
      std::cout<<'\n';
    }
    std::cout<<'\n';
    return;
  }
  std::cout<<a<<'\n';
  for (int i=0;i<n;++i)
    std::cout<<(a[i]=='.'?'#':'.');
  std::cout<<'\n';
  int x=0;
  for (int i=0;i<n;++i)
    if (a[i]=='#'&&((i&&a[i-1]=='.')||(i+1<n&&a[i+1]=='.'))){
      x=i;
      break;
    }
  int y=0;
  for (int i=0;i<n;++i)
    if (b[i]=='#'&&((i&&b[i-1]=='.')||(i+1<n&&b[i+1]=='.'))){
      y=i;
      break;
    }
  for (int i=0;i<n;++i)
    std::cout<<(i==x?'#':'.');
  std::cout<<'\n';
  int l=x,r=y;
  if (l>r) std::swap(l,r);
  if (l+1==r) --r;
  if (l+1<r) ++l,--r;
  for (int i=0;i<n;++i)
    std::cout<<(i>=l&&i<=r?'#':'.');
  std::cout<<'\n';
  for (int i=0;i<n;++i)
    std::cout<<(i==y?'#':'.');
  std::cout<<'\n';
  for (int i=0;i<n;++i)
    std::cout<<(b[i]=='.'?'#':'.');
  std::cout<<'\n';
  std::cout<<b<<'\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int t=1;
  std::cin >> t;
  while (t--) {
    work();
  }
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3848kb

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 12ms
memory: 3588kb

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: 8ms
memory: 3672kb

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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: 12ms
memory: 3584kb

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 10ms
memory: 4332kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 11ms
memory: 4284kb

input:

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

output:

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

result:

ok Correct.