QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#870057 | #9621. 连方 | Mini_PEKKA | AC ✓ | 13ms | 4224kb | C++14 | 1.6kb | 2025-01-25 14:37:18 | 2025-01-25 14:37:26 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
using namespace std;
using ll = long long;
const ll N = 200010;
ll n;
char a[N], b[N];
void solve() {
cin >> n;
string s;
cin >> s;
bool dota = 0, dotb = 0;
rep(i, 1, n) {
a[i] = s[i - 1];
if (a[i] == '.') {
dota = 1;
}
}
cin >> s;
rep(i, 1, n) {
b[i] = s[i - 1];
if (b[i] == '.') {
dotb = 1;
}
}
if ((dota && !dotb) || (!dota && dotb)) {
cout << "No\n";
return;
}
cout << "Yes\n";
if (!dota && !dotb) {
rep(i, 1, 7) {
rep(j, 1, n) {
cout << '#';
}
cout << '\n';
}
return;
}
rep(i, 1, n) {
cout << a[i];
}
cout << '\n';
rep(i, 1, n) {
cout << (char)('#' + '.' - a[i]);
}
cout << '\n';
ll pa = 0, pb = 0;
rep(i, 1, n) {
if ((i <= n - 1 && a[i] == '#' && a[i + 1] == '.') || (i >= 2 && a[i] == '#' && a[i - 1] == '.')) {
pa = i;
}
if ((i <= n - 1 && b[i] == '#' && b[i + 1] == '.') || (i >= 2 && b[i] == '#' && b[i - 1] == '.')) {
pb = i;
}
}
rep(i, 1, n) {
cout << (i == pa ? '#' : '.');
}
cout << '\n';
if (abs(pa - pb) <= 1) {
rep(i, 1, n) {
cout << (i == pa ? '#' : '.');
}
} else {
rep(i, 1, n) {
cout << ((pa < i && i < pb) || (pb < i && i < pa) ? '#' : '.');
}
}
cout << '\n';
rep(i, 1, n) {
cout << (i == pb ? '#' : '.');
}
cout << '\n';
rep(i, 1, n) {
cout << (char)('#' + '.' - b[i]);
}
cout << '\n';
rep(i, 1, n) {
cout << b[i];
}
cout << '\n';
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
ll t;
cin >> t;
rep(i, 1, t) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3712kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. ...# ...# ..#. #..# .##. Yes ##.#. ..#.# ...#. ...#. ...#. #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... ......................#.... ......................#.... ......................#.... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 12ms
memory: 3840kb
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: 11ms
memory: 3584kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ................#........................ .................############............ .............................#........... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 13ms
memory: 3712kb
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: 13ms
memory: 3712kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ...#.. ....#. ..##.# ##..#. Yes .#.###### #.#...... ...#..... ....#.... .....#... .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .......#......................................... ........########...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 11ms
memory: 4096kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 10ms
memory: 4224kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.