QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#742339 | #9621. 连方 | yzhx# | AC ✓ | 18ms | 4356kb | C++11 | 1.8kb | 2024-11-13 16:24:34 | 2024-11-13 16:24:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define re
#define ll long long
#define in inline
const int _ = 1e5 + 23;
char s[8][_];
int n;
in void gz(int k, int o) {
int f = 0;
for (int i = 1; i <= n; ++i)
if (s[k][i] != '#') s[k + o][i] = '#';
for (int i = 1; i <= n; ++i)
if (((s[k + o][i + 1] == '#' && i + 1 <= n) || (s[k + o][i - 1] == '#' && i - 1 >= 1)) && s[k + o][i] != '#') {
s[k + o + o][i] = '#';
break;
}
}
in void solve() {
cin >> n;
cin >> s[1] + 1;
cin >> s[7] + 1;
int f1 = 1, f2 = 1;
for (int i = 1; i <= n; ++i) {
for (int j = 2; j <= 6; ++j) s[j][i] = '.';
if (s[1][i] == '.') f1 = 0;
}
for (int i = 1; i <= n; ++i)
if (s[7][i] == '.') f2 = 0;
if (f1 != f2) {
puts("No");
return;
}
if (f1 & f2) {
cout << "Yes\n";
for (int i = 1; i <= 7; ++i) {
for (int j = 1; j <= n; ++j) putchar('#');
puts("");
}
return;
}
gz(1, 1), gz(7, -1);
int a = 0, b = 0;
for (int i = 1; i <= n; ++i) {
if (s[3][i] == '#') a = i;
if (s[5][i] == '#') b = i;
}
if (a == b)
s[4][a] = '#';
else {
if (a > b) swap(a, b);
if (a + 1 == b)
s[4][a] = '#';
else {
for (int i = a + 1; i < b; ++i) s[4][i] = '#';
}
}
puts("Yes");
for (int k = 1; k <= 7; ++k) {
for (int i = 1; i <= n; ++i) {
putchar(s[k][i]);
s[k][i] = '.';
}
puts("");
}
}
int main() {
int T;
cin >> T;
while (T--) {
solve();
}
}
/*
2
4
#..#
.##.
5
#.#.#
.#.#.
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 17ms
memory: 3748kb
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: 12ms
memory: 3676kb
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: 3624kb
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: 12ms
memory: 3676kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... .#.... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... #........ #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 11ms
memory: 4356kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 11ms
memory: 4300kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.