QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#738501 | #9621. 连方 | ray | AC ✓ | 8ms | 4848kb | C++20 | 3.0kb | 2024-11-12 19:13:33 | 2024-11-12 19:13:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << '\n';
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;
template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& v) {
for (T& x : v) {
is >> x;
}
return is;
}
template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
for (int i = 0; i < (int)v.size(); i++) {
os << v[i] << (i + 1 != v.size() ? " " : "");
}
return os;
}
void solve() {
int n;
cin >> n;
string a, b;
cin >> a >> b;
int ok = 1;
string s(n, '#'), t(n, '.');
if (a == s && (b != s && b != t)) {
ok = 0;
}
if (b == s && (a != s && b != t)) {
ok = 0;
}
if (!ok) {
cout << "No\n";
return;
}
if (a == s || a == t) {
cout << "Yes\n";
cout << a << "\n";
for (int i = 2; i <= 7; i++) cout << b << "\n";
return;
}
auto Reverse = [&](const string& s) {
string res(s.size(), '.');
for (int i = 0; i < s.size(); i++) {
res[i] = (s[i] == '#' ? '.' : '#');
}
return res;
};
vector<string> str(8, string(n, '.'));
str[1] = a, str[7] = b;
str[2] = Reverse(a), str[6] = Reverse(b);
int p = -1, q = -1;
for (int i = 0; i < n; i++) {
if (str[2][i] == '.') {
if (i == 0 && str[2][i + 1] == '#') {
p = i;
break;
} else if (i == n - 1 && str[2][i - 1] == '#') {
p = i;
break;
} else if (i > 0 && i < n - 1 && (str[2][i - 1] == '#' || str[2][i + 1] == '#')) {
p = i;
break;
}
}
}
// 同理
for (int i = 0; i < n; i++) {
if (str[6][i] == '.') {
if (i == 0 && str[6][i + 1] == '#') {
q = i;
break;
} else if (i == n - 1 && str[6][i - 1] == '#') {
q = i;
break;
} else if (i > 0 && i < n - 1 && (str[6][i - 1] == '#' || str[6][i + 1] == '#')) {
q = i;
break;
}
}
}
for (int i = 0; i < n; i++) {
if (i == p) str[3][i] = '#';
if (i == q) str[5][i] = '#';
}
int mn = min(p, q), mx = max(p, q);
if (mn == mx || mn + 1 == mx) {
str[4][mn] = '#';
} else {
for (int i = mn + 1; i < mx; i++) {
str[4][i] = '#';
}
}
cout << "Yes\n";
for (int i = 1; i <= 7; i++) cout << str[i] << "\n";
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
//std::cout << std::fixed << std::setprecision(10);
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: 3504kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 8ms
memory: 3604kb
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: 8ms
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: 4ms
memory: 3768kb
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: 4ms
memory: 3664kb
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: 4848kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 3ms
memory: 4500kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.