QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#744616 | #9621. 连方 | wanggl# | AC ✓ | 18ms | 4180kb | C++17 | 2.4kb | 2024-11-13 22:37:51 | 2024-11-13 22:37:52 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10;
void solve()
{
int n;
std::cin >> n;
std::vector<vector<char>> v(8, vector<char>(n, '.'));
for (int i = 0; i < n; i++) std::cin >> v[1][i];
for (int i = 0; i < n; i++) std::cin >> v[7][i];
int ok1 = (count(v[1].begin(), v[1].end(), '#') == n);
int ok2 = (count(v[7].begin(), v[7].end(), '#') == n);
if (ok1 && !ok2) {
std::cout << "No\n";
return;
} else if (!ok1 && ok2) {
std::cout << "No\n";
return;
} else if (ok1 && ok2) {
std::cout << "Yes\n";
for (int i = 1; i<= 7; i++) {
for (int j = 0; j < n; j++) {
std::cout << v[1][j];
}
std::cout << '\n';
}
return;
}
std::cout << "Yes\n";
int l, r;
// 6
for (int i = 0; i < n; i++) {
if (v[7][i] == '#') v[6][i] = '.';
else v[6][i] = '#';
}
// 5
for (int i = 0; i < n; i++) {
if (v[6][i] == '#') {
if (i - 1 >= 0 && v[6][i - 1] == '.') {
v[5][i - 1] = '#';
l = i - 1;
break;
} else if (i + 1 < n && v[6][i + 1] == '.') {
v[5][i + 1] = '#';
l = i + 1;
break;
}
}
}
// 2
for (int i = 0; i < n; i++) {
if (v[1][i] == '#') v[2][i] = '.';
else v[2][i] = '#';
}
// 3
for (int i = 0; i < n; i++) {
if (v[2][i] == '#') {
if (i - 1 >= 0 && v[2][i - 1] == '.') {
v[3][i - 1] = '#';
r = i - 1;
break;
} else if (i + 1 < n && v[2][i + 1] == '.') {
v[3][i + 1] = '#';
r = i + 1;
break;
}
}
}
// 4
int mn = min(l, r), mx = max(l, r);
if (mx - mn == 1 || mx - mn == 0) {
v[4][mn] = '#';
} else {
for (int i = mn + 1; i < mx; i++) v[4][i] = '#';
}
for (int i = 1; i <= 7; i++) {
for (int j = 0; j < n; j++) {
std::cout << (v[i][j] == '#' ? '#' : '.');
}
std::cout << '\n';
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1;
cin >> t;
while (t--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3780kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 14ms
memory: 3680kb
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: 3672kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 18ms
memory: 3872kb
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: 18ms
memory: 3848kb
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: 4112kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 13ms
memory: 4180kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.