QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#744080 | #9621. 连方 | Touper | AC ✓ | 26ms | 4316kb | C++14 | 2.1kb | 2024-11-13 20:47:38 | 2024-11-13 20:47:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, P = 13331 , M = 2e3 + 10, Mod = 998244353, INF = 0x3f3f3f3f;
const double eps = 1e-8;
/* #define x first
#define y second */
#define MAXN 99999999
typedef unsigned long long ull;
typedef long long ll;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
char mp[8][N];
void Solved()
{
int n;
cin >> n;
for(int j = 1; j <= 7; j ++)
for(int i = 1; i <= n; i ++)
mp[j][i] = '.';
cin >> mp[1] + 1;
cin >> mp[7] + 1;
int cnt0 = 0, cnt1 = 0;
for(int i = 1; i <= n; i ++)
{
if(mp[1][i] == '#') cnt0 ++;
else mp[2][i] = '#';
if(mp[7][i] == '#') cnt1 ++;
else mp[6][i] = '#';
}
if((cnt0 == n && cnt1 != n) || (cnt1 == n && cnt0 != n))
{
cout << "No" << '\n';
return;
}
if(cnt0 == n)
{
cout << "Yes" << '\n';
for(int i = 1; i <= 7; i ++)
{
for(int j = 1; j <= n; j ++)
cout << '#';
cout << "\n";
}
return;
}
int t1 = 0, t2 = 0;
for(int i = 1; i <= n; i ++)
{
if(mp[1][i] == '#' && (mp[1][i + 1] == '.' || mp[1][i - 1] == '.'))
{
mp[3][i] = '#';
t1 = i;
break;
}
}
for(int i = 1; i <= n; i ++)
{
if(mp[7][i] == '#' && (mp[7][i + 1] == '.' || mp[7][i - 1] == '.'))
{
mp[5][i] = '#';
t2 = i;
break;
}
}
if(abs(t1 - t2) > 1)
for(int i = min(t1, t2) + 1; i <= max(t2, t1) - 1; i ++) mp[4][i] = '#';
else if(t1 == t2 || abs(t1 - t2) == 1)
mp[4][t1] = '#';
cout << "Yes" << "\n";
for(int i = 1; i <= 7; i ++)
{
for(int j = 1; j <= n; j ++)
{
cout << mp[i][j];
}
cout << "\n";
}
}
int main()
{
/* ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0); */
int t;
cin >> t;
//t = 1;
while (t --)
{
Solved();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3668kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 21ms
memory: 3628kb
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: 26ms
memory: 3712kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 26ms
memory: 3764kb
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: 19ms
memory: 3640kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ..#... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... .#....... #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 19ms
memory: 4244kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 19ms
memory: 4316kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.