QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#741045 | #9621. 连方 | supepapupu# | AC ✓ | 9ms | 4212kb | C++23 | 2.1kb | 2024-11-13 13:07:26 | 2024-11-13 13:07:28 |
Judging History
answer
#include <bits/stdc++.h>
#define DEBUG
#ifdef DEBUG
#define debug(x) cerr << #x << ": " << (x) << endl
#define print(x) cerr << x << ' '
#define println(x) cerr << x << endl
#else
#define debug(x)
#define print(x)
#define println(x)
#endif
#define x first
#define y second
#define el '\n'
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int N = 3e5 + 10, INF = 0x3f3f3f3f, mod = 998244353;
void solve() {
int n; cin >> n;
vector<string> g(7);
cin >> g[0] >> g[6];
if (count(g[0].begin(), g[0].end(), '#') == n && count(g[6].begin(), g[6].end(), '#') == n) {
for (int i = 1; i <= 5; ++i)
for (int j = 0; j < n; ++j) g[i] += '#';
} else if (count(g[0].begin(), g[0].end(), '#') == n || count(g[6].begin(), g[6].end(), '#') == n) return cout << "NO\n", void();
else {
for (int i = 1; i <= 5; ++i)
for (int j = 0; j < n; ++j) g[i] += '.';
for (int i = 0; i < n; ++i)
if (g[0][i] == '#') g[1][i] = '.';
else g[1][i] = '#';
int p;
for (int i = 0; i < n; ++i) {
if (g[1][i] == '.' && (i - 1 >= 0 && g[1][i - 1] == '#' || i + 1 < n && g[1][i + 1] == '#')) {
g[2][i] = '#';
p = i;
break;
}
}
for (int i = 0; i < n; ++i)
if (g[6][i] == '#') g[5][i] = '.';
else g[5][i] = '#';
int q;
for (int i = 0; i < n; ++i) {
if (g[5][i] == '.' && (i - 1 >= 0 && g[5][i - 1] == '#' || i + 1 < n && g[5][i + 1] == '#')) {
g[4][i] = '#';
q = i;
break;
}
}
if (abs(p - q) <= 1) g[3][p] = '#';
else {
if (p > q) swap(p, q);
for (int i = p + 1; i < q; ++i) g[3][i] = '#';
}
}
cout << "YES\n";
for (int i = 0; i < 7; ++i) cout << g[i] << el;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int tcase = 1;
cin >> tcase;
while (tcase--) solve();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3820kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
YES #..# .##. #... #... .#.. #..# .##. YES ##.#. ..#.# .#... .#... .#... #.#.. .#.## NO YES .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### YES ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 4ms
memory: 3692kb
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: 3816kb
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: 3664kb
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: 3692kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
NO YES ###... ...### ..#... ..#... .#.... ..##.# ##..#. YES .#.###### #.#...... .#....... .#....... #........ .#.##.... #.#..#### YES ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 5ms
memory: 4212kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
YES ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 0ms
memory: 4080kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
YES ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.