QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#747546 | #9621. 连方 | 0x3ea | AC ✓ | 17ms | 4164kb | C++17 | 4.0kb | 2024-11-14 17:29:28 | 2024-11-14 17:29:34 |
Judging History
answer
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll = long long;
using db = double;
const int mod = 998244353;
const db eps = 1e-6;
void solve()
{
// cout << "here" << endl;
int n, cnt1 = 0, cnt2 = 0;
cin >> n;
vector<vector<char>> a(8, vector<char>(n + 2, '.'));
auto chk = [&]() -> bool
{
for (int i = 1; i <= n; i++)
cnt1 += a[1][i] == '.', cnt2 += a[7][i] == '.';
if ((cnt1 && !cnt2) || (!cnt1 && cnt2))
return 0;
return 1;
};
for (int i = 1; i <= n; i++)
cin >> a[1][i];
for (int i = 1; i <= n; i++)
cin >> a[7][i];
if (!chk())
{
cout << "No" << endl;
return;
}
cout << "Yes" << endl;
if (cnt1 + cnt2 == 0)
{
for (int i = 2; i <= 6; i++)
for (int j = 1; j <= n; j++)
a[i][j] = '#';
}
else
{
int l = 0, r = 0;
for (int i = 1; i <= n; i++)
if (a[1][i] == '.')
{
if (!l)
l = i;
r = i;
}
else
{
if (l > 1 && r < n)
for (int j = l; j <= r; j++)
a[2][j] = '#';
l = r = 0;
}
for (int i = 1; i <= n; i++)
if (a[7][i] == '.')
{
if (!l)
l = i;
r = i;
}
else
{
if (l > 1 && r < n)
for (int j = l; j <= r; j++)
a[6][j] = '#';
l = r = 0;
}
int l1 = 0, r1 = 0, l2 = 0, r2 = 0;
for (int i = 1; i <= n; i++)
{
if (a[1][i - 1] == '#' && a[1][i] == '.')
l1 = i;
if (a[1][i] == '.' && a[1][i + 1] == '#')
r1 = i;
if (a[7][i - 1] == '#' && a[7][i] == '.')
l2 = i;
if (a[7][i] == '.' && a[7][i + 1] == '#')
r2 = i;
}
if (l1 && l2)
{
a[2][l1] = '#';
a[3][l1 - 1] = '#';
a[5][l2 - 1] = '#';
a[6][l2] = '#';
for (int i = min(l1 - 1, l2 - 1) + 1; i <= max(l1 - 1, l2 - 1) - 1; i++)
a[4][i] = '#';
if (abs((l1 - 1) - (l2 - 1)) < 2)
a[4][l1 - 1] = '#';
}
else if (l1 && r2)
{
a[2][l1] = '#';
a[3][l1 - 1] = '#';
a[5][r2 + 1] = '#';
a[6][r2] = '#';
for (int i = min(l1 - 1, r2 + 1) + 1; i <= max(l1 - 1, r2 + 1) - 1; i++)
a[4][i] = '#';
if (abs((l1 - 1) - (r2 + 1)) < 2)
a[4][l1 - 1] = '#';
}
else if (r1 && l2)
{
a[2][r1] = '#';
a[3][r1 + 1] = '#';
a[5][l2 - 1] = '#';
a[6][l2] = '#';
for (int i = min(r1 + 1, l2 - 1) + 1; i <= max(r1 + 1, l2 - 1) - 1; i++)
a[4][i] = '#';
if (abs((r1 + 1) - (l2 - 1)) < 2)
a[4][r1 + 1] = '#';
}
else
{
a[2][r1] = '#';
a[3][r1 + 1] = '#';
a[5][r2 + 1] = '#';
a[6][r2] = '#';
for (int i = min(r1 + 1, r2 + 1) + 1; i <= max(r1 + 1, r2 + 1) - 1; i++)
a[4][i] = '#';
if (abs((r1 + 1) - (r2 + 1)) < 2)
a[4][r1 + 1] = '#';
}
}
for (int i = 1; i <= 7; i++)
{
for (int j = 1; j <= n; j++)
cout << a[i][j];
cout << endl;
}
}
int main()
{
#ifdef x3ea
freopen("in.txt", "r", stdin);
#endif
cout << fixed << setprecision(11);
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int _ = 1;
cin >> _;
for (; _; _--)
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... .#.. ..#. ...# .##. Yes ##.#. ..#.# ...#. ..#.. .#... ..#.. .#.## No Yes .######.######.####.#.##### .......#......#....#.#..... ....................#...... ...............#####....... ..............#............ .....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 13ms
memory: 3556kb
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: 17ms
memory: 3616kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ..............#.......................... ...............############.............. ...........................#............. ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 10ms
memory: 3560kb
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: 14ms
memory: 3616kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...#.. ..#... ...#.. ....#. ..##.# ##..#. Yes .#.###### ..#...... .#....... .#....... ..#...... .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......##########...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 10ms
memory: 4164kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 17ms
memory: 4100kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.