QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#751770 | #9621. 连方 | abbcc_1# | AC ✓ | 15ms | 4528kb | C++20 | 3.1kb | 2024-11-15 20:38:14 | 2024-11-15 20:38:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int kase;
cin >> kase;
while (kase--) {
int n;
cin >> n;
vector<vector<char>> s(7, vector<char>(n, '.'));
string a, b;
cin >> a >> b;
int upfirst = -1, downlast = -1;
int cnt = 0;
for (int i = 0; i < n; i += 1) {
s[0][i] = a[i];
s[6][i] = b[i];
cnt += (a[i] == '#');
cnt += (b[i] == '#');
}
if (cnt == 0) {
for (int i = 0; i < 7; i += 1) {
cout << a << '\n';
}
continue;
}
auto chk = [&](string x)->bool{
for (int i = 0; i < n; i += 1) {
if (x[i] != '.')return false;
}
return true;
};
for (int i = 0; i < n; i += 1) {
if (s[0][i] == '.') {
s[1][i] = '#';
if (upfirst == -1) {
upfirst = i;
}
}
if (s[6][i] == '.') {
s[5][i] = '#';
downlast = i;
}
}
if (upfirst == -1 && downlast == -1) {
cout << "Yes\n";
for (int i = 0; i < 7; i += 1) {
cout << a << '\n';
}
} else if (upfirst == -1 && downlast != -1) {
cout << "No\n";
} else if (upfirst != -1 && downlast == -1) {
cout << "No\n";
} else {
cout << "Yes\n";
int l = -1, r = -1;
for (int i = 0; i < n; i += 1) {
if (s[1][i] == '.' && l == -1) {
if (i - 1 >= 0 && s[1][i - 1] == '#' || i + 1 < n && s[1][i + 1] == '#') {
s[2][i] = '#';
l = i;
}
}
if (s[5][i] == '.' && r == -1) {
if (i - 1 >= 0 && s[5][i - 1] == '#' || i + 1 < n && s[5][i + 1] == '#') {
s[4][i] = '#';
r = i;
}
}
}
if (l > r) {
swap(l, r);
}
if (l == r) {
s[3][l] = '#';
} else if (l == r - 1 ) {
s[3][l] = '#';
} else {
for (int i = l + 1; i < r; i += 1) {
s[3][i] = '#';
}
}
for (int i = 0; i < 7; i += 1) {
for (int j = 0; j < n; j += 1) {
cout << s[i][j];
}
cout << '\n';
}
}
}
return 0;
}
/*
4
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
5
8
##.#.#.#
.......#
10
###.##.###
#.##..##.#
9
..###....
....#....
9
##...####
....#....
9
##...####
##...####
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3856kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 15ms
memory: 3668kb
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: 6ms
memory: 3932kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 11ms
memory: 3692kb
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: 15ms
memory: 3892kb
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: 4472kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 14ms
memory: 4528kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.