QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#737053 | #9621. 连方 | rikka_lyly# | AC ✓ | 7ms | 3988kb | C++20 | 1.9kb | 2024-11-12 14:28:03 | 2024-11-12 14:28:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
void solve()
{
int n;
cin >> n;
vector<string> s(7);
cin >> s[0] >> s[6];
bool all0 = 1, all6 = 1;
for (int i = 0; i < n; i++)
{
if(s[0][i] == '.')
all0 = 0;
}
for (int i = 0; i < n; i++)
{
if(s[6][i] == '.')
all6 = 0;
}
if(all0 && all6)
{
cout << "Yes\n";
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < n; j++)
{
cout << '#';
}
cout << '\n';
}
return;
}
else if(all0 || all6)
{
cout << "No\n";
return;
}
int p1 = -1, p2 = -1;
for (int i = 1; i <= 5; i++)
{
s[i].resize(n, '.');
}
for (int i = 0; i < n; i++)
{
if(s[0][i] == '.')
s[1][i] = '#';
if(s[6][i] == '.')
s[5][i] = '#';
}
for (int i = 0; i < n; i++)
{
if(s[1][i] == '.' && (i > 0 && s[1][i - 1] == '#' || i < n - 1 && s[1][i + 1] == '#'))
{
p1 = i;
break;
}
}
for (int i = 0; i < n; i++)
{
if(s[5][i] == '.' && (i > 0 && s[5][i - 1] == '#' || i < n - 1 && s[5][i + 1] == '#'))
{
p2 = i;
break;
}
}
s[2][p1] = '#', s[4][p2] = '#';
if(p1 == p2)
s[3][p1] = '#';
else if(abs(p1 - p2) == 1)
s[3][p1] = '#';
else
{
for (int i = min(p1, p2) + 1; i <= max(p1, p2) - 1; i++)
{
s[3][i] = '#';
}
}
cout << "Yes\n";
for (int i = 0; i < 7; i++)
{
cout << s[i] << '\n';
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t;
cin >> t;
while (t--)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3516kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 3ms
memory: 3636kb
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: 3836kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 7ms
memory: 3836kb
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: 6ms
memory: 3632kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ..#... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... .#....... #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 0ms
memory: 3896kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 4ms
memory: 3988kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.