QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#789073 | #9621. 连方 | Sword1E1 | AC ✓ | 14ms | 4676kb | C++20 | 1.6kb | 2024-11-27 19:13:34 | 2024-11-27 19:13:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
char ans[10][maxn];
void solve() {
int n;cin >> n;
string a,b;cin >> a >> b;
string res = "";
for (int i = 1;i <= n;i++) res += '#';
if (a == res && b == res) {
cout << "Yes" << '\n';
for (int i = 1;i <= 7;i++) cout << a << '\n';
return ;
}
if (a == res || b == res) {
cout << "No" << '\n';
return ;
}
cout << "Yes" << '\n';
for (int i = 0;i < n;i++) ans[1][i] = a[i],ans[7][i] = b[i];
for (int i = 0;i < n;i++) {
if (a[i] == '.') ans[2][i] = '#';
else ans[2][i] = '.';
if (b[i] == '.') ans[6][i] = '#';
else ans[6][i] = '.';
}
int p1 = -1;
for (int i = 0;i < n;i++) {
int l = max(i - 1,0);
int r = min(i + 1,n - 1);
if (ans[2][i] == '.' && (ans[2][l] == '#' || ans[2][r] == '#')) p1 = i;
}
int p2 = -1;
for (int i = 0;i < n;i++) {
int l = max(i - 1,0);
int r = min(i + 1,n - 1);
if (ans[6][i] == '.' && (ans[6][l] == '#' || ans[6][r] == '#')) p2 = i;
}
for (int i = 0;i < n;i++) {
if (i == p1) ans[3][i] = '#';
else ans[3][i] = '.';
}
for (int i = 0;i < n;i++) {
if (i == p2) ans[5][i] = '#';
else ans[5][i] = '.';
}
if (p1 > p2) swap(p1,p2);
for (int i = 0;i < n;i++) {
if (i > p1 && i < p2) ans[4][i] = '#';
else ans[4][i] = '.';
}
if (p1 == p2 || p2 - p1 == 1) ans[4][p1] = '#';
for (int i = 1;i <= 7;i++) {
for (int j = 0;j < n;j++) cout << ans[i][j];
cout << '\n';
}
}
signed main() {
ios::sync_with_stdio(false);cin.tie(0);
int t = 1;
cin >> t;
while (t--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. ...# ..#. ..#. #..# .##. Yes ##.#. ..#.# ...#. ...#. ...#. #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... ......................#.... ......................#.... ......................#.... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 14ms
memory: 3688kb
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: 14ms
memory: 3628kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ................#........................ .................############............ .............................#........... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 14ms
memory: 3908kb
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: 14ms
memory: 3748kb
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: 4676kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 9ms
memory: 4672kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.