QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#750383 | #9621. 连方 | ucup-team1329# | AC ✓ | 16ms | 6964kb | C++17 | 2.1kb | 2024-11-15 14:25:34 | 2024-11-15 14:25:35 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
using A2 = std::array<i64, 2>;
#define Fast_IOS \
std::ios::sync_with_stdio(false), \
std::cin.tie(0), \
std::cout.tie(0)
const i64 mod = 998244353;
int N, T = 1;
void init() {
Fast_IOS;
std::cin >> T;
}
void solve() {
int n;
std::cin >> n;
std::string a, b;
std::cin >> a >> b;
if (a == std::string(n, '.')) {
std::cout << "Yes\n";
std::cout << a << '\n';
std::string c;
for (int i = 0; i < n; i++) {
c.push_back(b[i] == '#' ? '.' : '#');
}
for (int i = 1; i < 6; i++) {
std::cout << c << '\n';
}
std::cout << b << '\n';
return;
}
if (b == std::string(n, '.')) {
std::cout << "Yes\n";
std::cout << a << '\n';
std::string c;
for (int i = 0; i < n; i++) {
c.push_back(a[i] == '#' ? '.' : '#');
}
for (int i = 1; i < 6; i++) {
std::cout << c << '\n';
}
std::cout << b << '\n';
return;
}
if (a == std::string(n, '#') && b == std::string(n, '#')) {
std::cout << "Yes\n";
for (int i = 0; i < 7; i++) {
std::cout << a << '\n';
}
return;
}
if (a == std::string(n, '#') || b == std::string(n, '#')) {
std::cout << "No\n";
return;
}
std::cout << "Yes\n";
std::vector ans(7, std::vector(n, 0));
for (int i = 0; i < n; i++) {
ans[0][i] = (a[i] == '#');
ans[6][i] = (b[i] == '#');
ans[1][i] = ans[0][i] ^ 1;
ans[5][i] = ans[6][i] ^ 1;
}
int l = 0, r = 0;
for (int i = 0; i < n; i++) {
if (!ans[1][i] && (i + 1 < n && ans[1][i + 1] || i - 1 >= 0 && ans[1][i - 1])) {
l = i;
ans[2][i] = 1;
break;
}
}
for (int i = 0; i < n; i++) {
if (!ans[5][i] && (i + 1 < n && ans[5][i + 1] || i - 1 >= 0 && ans[5][i - 1])) {
r = i;
ans[4][i] = 1;
break;
}
}
int pos = 0;
if (l > r) std::swap(l, r);
if (r - l <= 1) {
ans[3][l] = 1;
} else {
for (int i = l + 1; i <= r - 1; i++) {
ans[3][i] = 1;
}
}
for (int i = 0; i < 7; i++) {
for (int j = 0; j < n; j++) {
std::cout << (ans[i][j] ? '#' : '.');
}
std::cout << '\n';
}
}
int main() {
init();
while (T--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3864kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 15ms
memory: 3756kb
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: 16ms
memory: 3732kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 15ms
memory: 4000kb
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: 16ms
memory: 3732kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... .#.... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... #........ #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 13ms
memory: 6812kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 9ms
memory: 6964kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.