QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#743078 | #9621. 连方 | Zeoy# | AC ✓ | 13ms | 4400kb | C++20 | 3.1kb | 2024-11-13 18:10:12 | 2024-11-13 18:10:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int N = 100010;
int n;
char s[10][N];
string S;
void print() {
cout << "Yes\n";
for(int i = 1; i <= 7; i++) {
for(int j = 1; j <= n; j++) {
cout << s[i][j] ;
}
cout << endl;
}
cout << endl;
}
void solve() {
cin >> n;
int cnt1 = 0, cnt2 = 0;
cin >> S;
for (int i = 1; i <= n; ++i) s[1][i]= S[i - 1];
cin >> S;
for (int i = 1; i <= n; ++i) s[7][i] = S[i - 1];
for (int i = 2; i <= 6; ++i) {
for (int j = 1; j <= n; ++j) {
s[i][j] = '.';
}
}
for (int i = 1; i <= n; ++i) {
if (s[1][i] == '.') {
s[2][i] = '#';
}else cnt1++;
}
for (int i = 1; i <= n; ++i) {
if (s[7][i] == '.') {
s[6][i] = '#';
}else cnt2++;
}
if(cnt1 == n && cnt2 != n && cnt2 || cnt2 == n && cnt1 != n && cnt1) {
cout << "No\n";
return;
}
if(cnt1 == n && cnt2 == n) {
for(int i = 2; i <= 6; i++) {
for(int j = 1; j <= n; j++) s[i][j] = '#';
}
print();
return;
}
if(cnt1 == 0 && cnt2 == 0) {
for(int i = 2; i <= 6; i++) {
for(int j = 1; j <= n; j++) s[i][j] = '.';
}
print();
return;
}
if(cnt1 == 0) {
for(int i = 1; i <= n; i++) s[2][i] = '.';
print();
return;
}
if(cnt2 == 0) {
for(int i = 1; i <= n; i++) s[6][i] = '.';
print();
return;
}
int top = 0, down = 0;
for(int i = 1; i <= n; i++) {
if(i - 1 >= 1 && s[2][i] == '#' && s[2][i - 1] == '.') {
s[3][i - 1] = '#';
top = i - 1;
}
else if(i + 1 >= 1 && s[2][i] == '#' && s[2][i + 1] == '.') {
s[3][i + 1] = '#';
top = i + 1;
}
if(top) break;
}
for(int i = 1; i <= n; i++) {
if(i - 1 >= 1 && s[6][i] == '#' && s[6][i - 1] == '.') {
s[5][i - 1] = '#';
down = i - 1;
}
else if(i + 1 >= 1 && s[6][i] == '#' && s[6][i + 1] == '.') {
s[5][i + 1] = '#';
down = i + 1;
}
if(down) break;
}
if(top == down) {
s[4][top] = '#';
}
else if(top == down + 1 || top == down - 1) {
s[4][top] = '#';
}
else {
if(top > down) swap(top, down);
for(int i = top + 1; i < down; i++) {
s[4][i] = '#';
}
}
print();
}
/*
4
4
#..#
.##.
5
##.#.
.#.##
6
#######
.#####.
27
.######.######.####.#.#####
.####...####..#.......#####
*/
signed main() {
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int _= 1;
cin >> _;
// getchar();
while(_--) solve();
}
/*
.######.######.####.#.#####
.......#......#....#.#.....
...........................
...........................
.....###....##.#######.....
.####...####..#.......#####
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3716kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes #####...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 12ms
memory: 3656kb
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: 3640kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Y...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 12ms
memory: 3740kb
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: 3644kb
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: 4368kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 13ms
memory: 4400kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.