QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#753499 | #9621. 连方 | D12EQD# | AC ✓ | 21ms | 4364kb | C++17 | 2.0kb | 2024-11-16 13:05:45 | 2024-11-16 13:05:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 998244353;
void solve() {
int n;
cin >> n;
string a, b;
cin >> a >> b;
vector<string> ans(7, string(n, '0'));
for (int i = 0; a[i]; i++) a[i] = a[i] == '#' ? '1' : '0', b[i] = b[i] == '#' ? '1' : '0';
ans[0] = a, ans[6] = b;
for (int i = 0; a[i]; i++) {
if (a[i] == '1') ans[1][i] = '0';
else ans[1][i] = '1';
if (b[i] == '0') ans[5][i] = '1';
}
int l = -1, r = -1;
for (int i = 1; a[i]; i++) {
if (ans[1][i] != ans[1][i - 1]) {
if (ans[1][i] == '0') l = i;
else l = i - 1;
break;
}
}
for (int i = 1; a[i]; i++) {
if (ans[5][i] != ans[5][i - 1]) {
if (ans[5][i] == '0') r = i;
else r = i - 1;
break;
}
}
if (l == -1 || r == -1) {
if (l == -1 && r == -1) {
for (auto &c: a) c = c == '1' ? '#' : '.';
for (auto &c: b) c = c == '1' ? '#' : '.';
cout << "Yes\n";
if (a == b) for (int i = 0; i < 7; i++) cout << a << "\n";
else if (a[0] == '.') {
for (int i = 0; i < 6; i++) cout << a << "\n";
cout << b << "\n";
} else {
cout << a << "\n";
for (int i = 0; i < 6; i++) cout << b << "\n";
}
} else cout << "No\n";
} else {
ans[2][l] = '1', ans[4][r] = '1';
if (l > r)swap(l, r);
if (l == r || r - l == 1) ans[3][l] = '1';
else {
for (int i = l + 1; i < r; i++) ans[3][i] = '1';
}
cout << "Yes\n";
for (auto &x: ans) for (auto &c: x) c = c == '1' ? '#' : '.';
for (auto &x: ans) cout << x << "\n";
}
}
signed main() {
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
int T = 1;
cin >> T;
while (T--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 21ms
memory: 3648kb
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: 15ms
memory: 3652kb
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: 3672kb
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: 7ms
memory: 3672kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... .#.... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... #........ #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 4ms
memory: 4364kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 8ms
memory: 4252kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.