QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#737817 | #9621. 连方 | Nephrenn | AC ✓ | 15ms | 4012kb | C++20 | 2.7kb | 2024-11-12 16:55:25 | 2024-11-12 16:55:25 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
void solve() {
int n;
std::cin >> n;
std::vector<std::string> s(8);
std::cin >> s[1] >> s[7];
s[1] = " " + s[1], s[7] = " " + s[7];
for (int i = 2; i < 7; ++i) {
s[i].resize(n + 1);
}
bool f1 = 1, f2 = 1;
for (int i = 1; i <= n; ++i) {
if (s[1][i] == '.') f1 = 0;
if (s[7][i] == '.') f2 = 0;
}
if (f1 ^ f2) {
std::cout << "No\n";
return;
}
if (f1 && f2) {
std::cout << "Yes\n";
for (int i = 1; i <= 7; ++i) {
for (int j = 1; j <= n; ++j) {
std::cout << "#";
}
std::cout << "\n";
}
return;
}
for (int i = 1; i <= n; ++i) {
if (s[1][i] == '.') s[2][i] = '#';
else s[2][i] = '.';
if (s[7][i] == '.') s[6][i] = '#';
else s[6][i] = '.';
}
int l1 = 0, l2 = 0;
for (int i = 1; i <= n; ++i) {
if (s[2][i] == '.' && ( (i > 1 && s[2][i - 1] == '#') || (i < n && s[2][i + 1] == '#') )) {
l1 = i;
s[3][i] = '#';
break;
}
}
for (int i = 1; i <= n; ++i) {
if (i == l1) continue;
s[3][i] = '.';
}
for (int i = 1; i <= n; ++i) {
if (s[6][i] == '.' && ( (i > 1 && s[6][i - 1] == '#') || (i < n && s[6][i + 1] == '#') )) {
l2 = i;
s[5][i] = '#';
break;
}
}
for (int i = 1; i <= n; ++i) {
if (i == l2) continue;
s[5][i] = '.';
}
if (l1 > l2) std::swap(l1, l2);
if (l1 == l2) {
for (int i = 1; i <= n; ++i) {
if (i == l1) s[4][i] = '#';
else s[4][i] = '.';
}
} else if (l2 - l1 == 1) {
for (int i = 1; i <= l1; ++i) {
s[4][i] = '.';
}
for (int i = l1 + 1; i <= l2; ++i) {
s[4][i] = '#';
}
for (int i = l2 + 1; i <= n; ++i) {
s[4][i] = '.';
}
} else {
for (int i = 1; i <= l1; ++i) {
s[4][i] = '.';
}
for (int i = l1 + 1; i < l2; ++i) {
s[4][i] = '#';
}
for (int i = l2; i <= n; ++i) {
s[4][i] = '.';
}
}
std::cout << "Yes\n";
for (int i = 1; i <= 7; ++i) {
for (int j = 1; j <= n; ++j) {
std::cout << s[i][j];
}
std::cout << "\n";
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t = 1;
std::cin >> t;
while(t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... .#.. .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 15ms
memory: 3696kb
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: 3724kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 9ms
memory: 3692kb
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: 3620kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ..#... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... .#....... #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 12ms
memory: 4012kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 11ms
memory: 4000kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.