QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#748410 | #9621. 连方 | AmiyaCast# | AC ✓ | 15ms | 4104kb | C++20 | 2.5kb | 2024-11-14 20:19:42 | 2024-11-14 20:19:42 |
Judging History
answer
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define pii pair<ll, ll>
const ll inf = 2e18;
const double eps = 1e-9;
using namespace std;
void slv(){
ll n; cin >> n;
string s[8];
cin >> s[1] >> s[7];
ll f1 = 0, f2 = 0;
for(auto c:s[1]) {
if(c == '.') f1 = 1;
}
for(auto c:s[7]) {
if(c == '.') f2 = 1;
}
if(!f1 || !f2) {
if(!f1 && !f2) {
cout << "Yes" << endl;
for(int i = 1; i <= 7; ++i) {
for(int j = 1; j <= n; ++j) {
cout << '#';
}
cout << endl;
}
} else {
cout << "No" << endl;
}
return ;
}
s[1] = " " + s[1], s[7] = " " + s[7];
for(int i = 2; i <= 6; ++i) {
s[i] = s[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] = '#';
}
}
for(int i = 1; i <= n; ++i) {
if(s[7][i] == '.') {
s[6][i] = '#';
}
}
int p1 = 0, p2 = 0;
for(int i = 1; i < n; ++i) {
if(s[2][i] != s[2][i + 1]) {
if(s[2][i] == '#') {
s[3][i + 1] = '#';
p1 = i + 1;
} else {
s[3][i] = '#';
p1 = i;
}
break;
}
}
for(int i = 1; i < n; ++i) {
if(s[6][i] != s[6][i + 1]) {
if(s[6][i] == '#') {
s[5][i + 1] = '#';
p2 = i + 1;
} else {
s[5][i] = '#';
p2 = i;
}
break;
}
}
if(abs(p1 - p2) <= 1) {
s[4][p1] = '#';
} else {
for(int i = min(p1, p2) + 1; i <= max(p1, p2) - 1; ++i) {
s[4][i] = '#';
}
}
cout << "Yes" << endl;
for(int i = 1; i <= 7; ++i) {
for(int j = 1; j <= n; ++j) {
cout << s[i][j];
}
cout << endl;
}
}
int main(){
ios::sync_with_stdio(0), cin.tie(0);
int _ = 1;
cin >> _;
while(_--) slv();
return 0;
}
/*
8
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
4
..##
##..
1
#
#
4
####
####
4
#.##
##.#
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3784kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 14ms
memory: 3844kb
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: 11ms
memory: 3680kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 14ms
memory: 3816kb
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: 3580kb
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: 4104kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 13ms
memory: 4036kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.