QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#795637 | #9621. 连方 | 1903331632 | AC ✓ | 16ms | 4168kb | C++23 | 2.4kb | 2024-11-30 22:27:53 | 2024-11-30 22:27:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(s) s.begin(), s.end()
#define int long long
#define endl '\n'
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
void solve()
{
int n;
cin >> n;
vector<string> mp(8, string(n + 10, '.'));
bool is1 = false, is2 = false;
for (int i = 1; i <= n; i++)
{
cin >> mp[1][i];
if (mp[1][i] == '.')
is1 = true;
}
for (int i = 1; i <= n; i++)
{
cin >> mp[7][i];
if (mp[7][i] == '.')
is2 = true;
}
if (!is1 && !is2)
{
cout << "Yes" << endl;
for (int i = 1; i <= 7; i++)
{
for (int j = 1; j <= n; j++)
{
cout << "#";
}
cout << endl;
}
return;
}
if (!is1 || !is2)
{
cout << "No" << endl;
return;
}
for (int i = 1; i <= n; i++)
{
if (mp[1][i] == '.')
mp[2][i] = '#';
else
mp[2][i] = '.';
}
for (int i = 1; i <= n; i++)
{
if (mp[7][i] == '.')
mp[6][i] = '#';
else
mp[6][i] = '.';
}
int l, r;
for (int i = 1; i <= n; i++)
{
if (mp[2][i] == '.' && ((i - 1 >= 1 && mp[2][i - 1] == '#') || (mp[2][i + 1] == '#' && i + 1 <= n)))
{
l = i;
break;
}
}
for (int i = 1; i <= n; i++)
{
if (mp[6][i] == '.' && ((i - 1 >= 1 && mp[6][i - 1] == '#') || (mp[6][i + 1] == '#' && i + 1 <= n)))
{
r = i;
break;
}
}
if (l == r)
{
for (int i = 3; i <= 5; i++)
{
mp[i][l] = '#';
}
}
else if (abs(l - r) == 1)
{
mp[3][l] = '#';
mp[4][l] = '#';
mp[5][r] = '#';
}
else
{
mp[3][l] = '#';
mp[5][r] = '#';
if (l > r)
swap(l, r);
for (int i = l + 1; i <= r - 1; i++)
{
mp[4][i] = '#';
}
}
cout << "Yes" << endl;
for (int i = 1; i <= 7; i++)
{
for (int j = 1; j <= n; j++)
{
cout << mp[i][j];
}
cout << endl;
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--)
solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3772kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 11ms
memory: 3672kb
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: 16ms
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: 16ms
memory: 3676kb
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: 3712kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ..#... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... .#....... #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 14ms
memory: 4168kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 10ms
memory: 4120kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.