QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#736513 | #9621. 连方 | baitang | AC ✓ | 15ms | 4248kb | C++20 | 1.7kb | 2024-11-12 11:31:17 | 2024-11-12 11:31:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int n;
cin >> n;
getchar();
vector<vector<char>>ch(7, vector<char>(n + 2));
for (int i = 0; i < n; i++)ch[0][i] = getchar();
getchar();
for (int i = 0; i < n; i++)ch[6][i] = getchar();
bool fla1 = 1, fla2 = 1;
for (int i = 0; i < n; i++)
{
if (ch[0][i] == '.')ch[1][i] = '#', fla1 = 0;
else ch[1][i] = '.';
if (ch[6][i] == '.')ch[5][i] = '#', fla2 = 0;
else ch[5][i] = '.';
}
if (fla1 && fla2)
{
printf("Yes\n");
for(int j=0;j<7;j++)
{
for (int i = 0; i < n; i++)
putchar('#');
putchar('\n');
}
return;
}
if ((!fla1) && fla2 || (!fla2) && fla1)
{
printf("No\n");
return;
}
int pla1, pla2;
for (int i = 0; i < n; i++)
{
if (ch[1][i] == '.' && (i<n-1&&ch[1][i + 1] == '#' || (i > 0 && ch[1][i - 1] == '#')))
{
pla1 = i;
break;
}
}
for (int i = 0; i < n; i++)
{
if (ch[5][i] == '.' && (i<n-1&&ch[5][i + 1] == '#' || (i > 0 && ch[5][i - 1] == '#')))
{
pla2 = i;
break;
}
}
for (int i = 0; i < n; i++)
{
if (i != pla1)ch[2][i] = '.';
else ch[2][i] = '#';
if(i != pla2)ch[4][i] = '.';
else ch[4][i] = '#';
}
if (pla1 == pla2||pla1-pla2==1||pla2-pla1==1)
{
for (int i = 0; i < n; i++)
{
if (i != pla1)ch[3][i] = '.';
else ch[3][i] = '#';
}
}
else
{
int tmp;
if (pla1 > pla2)tmp = pla1, pla1 = pla2, pla2 = tmp;
for (int i = 0; i < n; i++)
{
if (i > pla1 && i < pla2)ch[3][i] = '#';
else ch[3][i] = '.';
}
}
printf("Yes\n");
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < n; j++)
putchar(ch[i][j]);
putchar('\n');
}
return;
}
int main()
{
int t;
cin >> t;
while (t--)solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3728kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 9ms
memory: 3812kb
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: 15ms
memory: 3944kb
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: 3712kb
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: 13ms
memory: 3776kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ..#... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... .#....... #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 7ms
memory: 4100kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 8ms
memory: 4248kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.