QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#737109#9621. 连方ehdxbcAC ✓16ms4312kbC++202.0kb2024-11-12 14:39:142024-11-12 14:39:33

Judging History

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

  • [2024-11-12 14:39:33]
  • 评测
  • 测评结果:AC
  • 用时:16ms
  • 内存:4312kb
  • [2024-11-12 14:39:14]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
void solve() {
   int n;
   cin >> n;
   string a, b;
   cin >> a >> b;
   int t = count(a.begin(), a.end(), '#');
   int t1 = count(b.begin(), b.end(), '#');
   // cerr << t << " " << t1 << endl;
   if (t == n) {
      if (t1 == n) {
         cout << "Yes\n";
         for (int i = 0; i < 7; i++) {
            cout << a << endl;
         }
      } else {
         cout << "No\n";
      }
      return;
   } else {
      if (t1 == n) {
         cout << "No\n";
        return;
      }
   }
   cout << "Yes\n";
   string s2, s6;
   for (int i = 0; i < n; i++) {
      if (a[i] == '#') s2 += '.';
      else {
         s2 += '#';
      }
   }
   string s3 = string(n, '.');
   int f1 = 0, f2 = 0;
   for (int i = 1; i < n; i++) {
      if (s2[i] != s2[i - 1]) {
         if (s2[i] == '#') {
            s3[i - 1] = '#';
            f1 = i - 1;
         } else {
            s3[i] = '#';
            f1 = i;
         }
         break;
      }
   }
   for (int i = 0; i < n; i++) {
      if (b[i] == '#') s6 += '.';
      else {
         s6 += '#';
      }
   }
   string s5 = string(n, '.');
   for (int i = 1; i < n; i++) {
      if (s6[i] != s6[i - 1]) {
         if (s6[i] == '#') {
            s5[i - 1] = '#';
            f2 = i - 1;
         } else {
            s5[i] = '#';
            f2 = i;
         }
         break;
      }
   }
   string s4 = string(n, '.');
   if (f1 == f2) {
      s4[f1] = '#';
   } else if (abs(f1 - f2) == 1) {
      s4[f1] = '#';
   } else {
      if (f1 > f2) swap(f1, f2);
      for (int i = f1 + 1; i < f2; i++) {
         s4[i] = '#';
      }
   }
   cout << a << endl;
   cout << s2 << endl;
   cout << s3 << endl;
   cout << s4 << endl;
   cout << s5 << endl;
   cout << s6 << endl;
   cout << b << endl;
}
signed main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int t;
   cin >> t;
   while (t--) {
      solve();
   }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 16ms
memory: 3928kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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: 15ms
memory: 3624kb

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.