QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#741940 | #9621. 连方 | chatoyane# | AC ✓ | 3ms | 4468kb | C++20 | 2.6kb | 2024-11-13 15:31:08 | 2024-11-13 15:31:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using db = double;
#define endl '\n'
void solve()
{
int n;
cin >> n;
string a, b;
cin >> a >> b;
vector<string> s(7);
s[0] = a, s[6] = b;
for (int i = 1; i < 6; ++i)
{
s[i] = string(n, '.');
}
if (a == string(n, '.') || b == string(n, '.'))
{
if (a == b)
{
cout << "Yes" << endl;
for (auto x : s)
cout << x << endl;
return;
}
if (a == string(n, '.'))
{
for (int i = 0; i < n; ++i)
s[5][i] = (b[i] ^ '#' ^ '.');
cout << "Yes" << endl;
for (auto x : s)
cout << x << endl;
}
else
{
for (int i = 0; i < n; ++i)
s[1][i] = (a[i] ^ '#' ^ '.');
cout << "Yes" << endl;
for (auto x : s)
cout << x << endl;
}
return;
}
if (a == string(n, '#') || b == string(n, '#'))
{
if (a == b)
{
cout << "Yes" << endl;
for (int i = 0; i < 7; ++i)
cout << a << endl;
}
else
cout << "No" << endl;
return;
}
for (int i = 0; i < n; ++i)
s[1][i] = (a[i] ^ '#' ^ '.');
for (int i = 0; i < n; ++i)
s[5][i] = (b[i] ^ '#' ^ '.');
int p1 = -1, p2 = -1;
for (int i = 0; i < n; ++i)
{
if (s[1][i] == '.')
{
if (i - 1 >= 0 && s[1][i - 1] == '#')
{
p1 = i;
break;
}
if (i + 1 < n && s[1][i + 1] == '#')
{
p1 = i;
break;
}
}
}
for (int i = 0; i < n; ++i)
{
if (s[5][i] == '.')
{
if (i - 1 >= 0 && s[5][i - 1] == '#')
{
p2 = i;
break;
}
if (i + 1 < n && s[5][i + 1] == '#')
{
p2 = i;
break;
}
}
}
s[2][p1] = '#', s[4][p2] = '#';
if (abs(p1 - p2) <= 1)
s[3][p1] = '#';
else
{
for (int i = min(p1, p2) + 1; i < max(p1, p2); ++i)
s[3][i] = '#';
}
cout << "Yes" << endl;
for (auto x : s)
cout << x << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--)
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3528kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 3ms
memory: 3544kb
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: 3ms
memory: 3816kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 3ms
memory: 3652kb
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: 3ms
memory: 3552kb
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: 4468kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 0ms
memory: 4452kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.