QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#746327 | #9621. 连方 | ganking# | AC ✓ | 14ms | 4184kb | C++20 | 2.1kb | 2024-11-14 14:15:34 | 2024-11-14 14:15:35 |
Judging History
answer
#include<bits/stdc++.h>
#define fo(i,a,b) for (ll (i)=(a);(i)<=(b);(i)++)
#define ll long long
#define db long double
using namespace std;
const int N = 5e5 + 10;
const int mo = 998244353;
string s, t, ans[10];
int n;
void solve() {
cin >> n >> s >> t;
s = " " + s;
t = " " + t;
fo(i, 1, 7) ans[i].resize(n+1);
int f1 = 1, f2 = 1;
fo(i, 1, n) {
if (s[i] == '.') f1 = 0;
if (t[i] == '.') f2 = 0;
}
if (f1 && f2) {
cout << "Yes\n";
fo(i, 1, 7) {
fo(j, 1, n) cout << "#";
cout << "\n";
}
return;
}
if (f1 != f2) {
cout << "No\n";
return;
}
fo(i, 1, n) {
ans[1][i] = s[i];
ans[7][i] = t[i];
}
fo(i, 1, n) {
if (s[i] == '.') ans[2][i] = '#';
else ans[2][i] = '.';
if (t[i] == '.') ans[6][i] = '#';
else ans[6][i] = '.';
}
int l, r;
fo(i, 1, n) {
if (ans[2][i] == '.') {
if (i < n && ans[2][i + 1] == '#') {
l = i;break;
}
if (i > 1 && ans[2][i - 1] == '#') {
l = i;break;
}
}
}
fo(i, 1, n) {
if (ans[6][i] == '.') {
if (i < n && ans[6][i + 1] == '#') {
r = i;break;
}
if (i > 1 && ans[6][i - 1] == '#') {
r = i;break;
}
}
}
fo(i, 3, 5) {
fo(j, 1, n) ans[i][j] = '.';
}
// cout << l << " " << r << "\n";
if (l == r) {
ans[3][l] = ans[4][l] = ans[5][l] = '#';
}
else if (abs(r - l) == 1) {
ans[3][l] = ans[4][l] = ans[5][r] = '#';
}
else {
ans[3][l] = ans[5][r] = '#';
fo(j, min(l,r)+ 1, max(l,r) - 1) ans[4][j] = '#';
}
cout << "Yes\n";
fo(i, 1, 7) {
fo(j, 1, n) cout << ans[i][j];
cout << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
cin >> T;
while (T--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 13ms
memory: 3616kb
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: 3664kb
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: 3896kb
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: 3696kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ..#... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... .#....... #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 3ms
memory: 4184kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 11ms
memory: 4048kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.