QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#737720 | #9621. 连方 | chronobox | AC ✓ | 13ms | 4536kb | C++20 | 2.8kb | 2024-11-12 16:42:27 | 2024-11-12 16:42:27 |
Judging History
answer
#include <bits/stdc++.h>
char g[8][100010];
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0); std:: cout.tie(0);
int t; std:: cin >> t;
while(t--) {
int n; std::string s1, s2;
std:: cin >> n >> s1 >> s2;
if(std::count(s1.begin(), s1.end(),'#') == n && std::count(s2.begin(), s2.end(),'#') != n) {
std:: cout << "No\n";
continue;
}
if(std::count(s1.begin(), s1.end(),'#') != n && std::count(s2.begin(), s2.end(),'#') == n) {
std:: cout << "No\n";
continue;
}
std:: cout << "Yes\n";
if(std::count(s1.begin(), s1.end(),'#') == n && std::count(s2.begin(), s2.end(),'#') == n) {
for(int i = 1; i <= 7; i++) {
for(int j = 1; j <= n; j++) {
std:: cout << '#';
}
std:: cout << '\n';
}
continue;
}
for(int i = 1; i <= 7; i++)
for(int j = 1; j <= n; j++)
g[i][j] = '.';
for(int i = 1; i <= n; i++) g[1][i] = s1[i - 1];
for(int i = 1; i <= n; i++) g[2][i] = ((s1[i - 1] == '#') ? '.' : '#');
for(int i = 1; i <= n; i++) g[7][i] = s2[i - 1];
for(int i = 1; i <= n; i++) g[6][i] = ((s2[i - 1] == '#') ? '.' : '#');
if(!std::count(s1.begin(), s1.end(),'#') || !std::count(s2.begin(), s2.end(),'#')) {
for(int i = 1; i <= 7; i++) {
for(int j = 1; j <= n; j++) {
std:: cout << g[i][j];
}
std:: cout << '\n';
}
continue;
}
int l1 = 0, r1 = 0, l2 = n + 1, r2 = n + 1;
for(int i = 1; i <= n; i++) {
if(g[2][i] == '#') {
l1 = r1 = i;
while(r1 < n && g[2][r1 + 1] == '#') r1++;
break;
}
}
for(int i = n; i; i--) {
if(g[6][i] == '#') {
l2 = r2 = i;
while(l2 > 1 && g[6][l2 - 1] == '#') l2--;
break;
}
}
int x1, x2;
if(l1 > 1) x1 = l1 - 1;
else x1 = r1 + 1;
if(r2 < n) x2 = r2 + 1;
else x2 = l2 - 1;
//std:: cout << l1 << ' ' << r1 << ' ' << l2 << ' ' << r2 << '\n';
g[3][x1] = g[5][x2] = '#';
if(abs(x1 -x2) <= 1) g[4][x1] = '#';
else if(x1 < x2) {
for(int i = x1 + 1; i <= x2 - 1; i++) g[4][i] = '#';
} else {
for(int i = x2 + 1; i <= x1 - 1; i++) g[4][i] = '#';
}
for(int i = 1; i <= 7; i++) {
for(int j = 1; j <= n; j++) {
std:: cout << g[i][j];
}
std:: cout << '\n';
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... .#.. ..#. #..# .##. Yes ##.#. ..#.# .#... ..#.. ...#. #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... ..####################..... ......................#.... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 13ms
memory: 3884kb
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: 13ms
memory: 3756kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......######################............ .............................#........... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 13ms
memory: 3756kb
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: 13ms
memory: 3660kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ...#.. ....#. ..##.# ##..#. Yes .#.###### #.#...... .#....... ..###.... .....#... .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......##########...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 8ms
memory: 4536kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 11ms
memory: 4532kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.