QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#762644 | #9621. 连方 | superguymj# | AC ✓ | 8ms | 4376kb | C++20 | 2.2kb | 2024-11-19 15:58:49 | 2024-11-19 15:58:51 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,x,y) for (int i = x; i <= y; i++)
#define repd(i,x,y) for (int i = x; i >= y; i--)
#define mid ((l + r) >> 1)
#define lch (rt << 1)
#define rch (rt << 1 | 1)
using namespace std;
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
void solve() {
int n;
cin >> n;
string s, t;
cin >> s >> t;
if (s == string(n, '#')) {
if (t == string(n, '.') || t == string(n, '#')) {
cout << "Yes\n";
cout << s << '\n';
rep(i,2,7) {
cout << t << '\n';
}
return;
}
cout << "No\n";
return;
}
swap(s, t);
if (s == string(n, '#')) {
if (t == string(n, '.') || t == string(n, '#')) {
cout << "Yes\n";
cout << t << '\n';
rep(i,2,7) {
cout << s << '\n';
}
return;
}
cout << "No\n";
return;
}
swap(s, t);
vector<string> ans(7, string(n, '.'));
ans[0] = s, ans.back() = t;
if (s[0] == '.' && s[1] == '.') {
ans[0][0] = '#';
}
if (t[0] == '.' && t[1] == '.') {
ans.back()[0] = '#';
}
rep(i,0,n-1) {
if (ans[0][i] == '#') {
ans[1][i] = '.';
} else {
ans[1][i] = '#';
}
if (ans.back()[i] == '#') {
ans.end()[-2][i] = '.';
} else {
ans.end()[-2][i] = '#';
}
}
int x = find(ans[1].begin(), ans[1].end(), '#') - ans[1].begin();
rep(j,1,x-1) {
ans[2][j] = '#';
}
if (ans[2] == string(n, '.')) {
ans[2][0] = '#';
}
int y = find(ans[5].begin(), ans[5].end(), '#') - ans[5].begin();
rep(j,1,y-1) {
ans[4][j] = '#';
}
if (ans[4] == string(n, '.')) {
ans[4][0] = '#';
}
ans[3][0] = '#';
ans[0] = s;
ans.back() = t;
cout << "Yes\n";
for (auto a : ans) {
cout << a << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while (T--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... #... #..# .##. Yes ##.#. ..#.# .#... #.... #.... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... #.......................... #.......................... #.......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 8ms
memory: 3752kb
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: 4ms
memory: 3652kb
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: 3892kb
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: 8ms
memory: 3952kb
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: 4376kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 3ms
memory: 4264kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.