QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#758761 | #9621. 连方 | OMoonStars | AC ✓ | 44ms | 4260kb | C++14 | 1.7kb | 2024-11-17 19:37:46 | 2024-11-17 19:37:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int n;
cin >> n;
string s[10];
cin >> s[1] >> s[7];
int a = 0, b = 0;
for(int i = 0; i < n; i ++)
{
if(s[1][i] == '.') a = 1;
if(s[7][i] == '.') b = 1;
}
if(a != b) return cout << "NO" << endl, void();
else cout << "YES" << endl;
if(a == 0 && b == 0)
{
for(int i = 0; i < 7; i ++)
cout << s[1] << endl;
return;
}
for(int i = 0; i < n; i ++)
{
if(s[1][i] == '.') s[2] += '#';
else s[2] += '.';
if(s[7][i] == '.') s[6] += '#';
else s[6] += '.';
}
int flag1 = -1, flag2 = -1;
for(int i = 0; i < n; i ++)
{
if(flag1 == -1 && s[2][i] == '.' && ((i > 0 && s[2][i - 1] == '#') || (i < n - 1 && s[2][i + 1] == '#')))
{
s[3] += '#';
flag1 = i;
}
else
s[3] += '.';
if(flag2 == -1 && s[6][i] == '.' && ((i > 0 && s[6][i - 1] == '#') || (i < n - 1 && s[6][i + 1] == '#')))
{
s[5] += '#';
flag2 = i;
}
else
s[5] += '.';
}
if(flag1 > flag2) swap(flag1, flag2);
if(flag2 - flag1 <= 1)
{
for(int i = 0; i < n; i ++)
{
if(i != flag1) s[4] +='.';
else s[4] += '#';
}
}
else
{
for(int i = 0; i <= flag1; i ++) s[4] += '.';
for(int i = flag1 + 1; i < flag2; i ++) s[4] += '#';
for(int i = flag2; i < n; i ++) s[4] += '.';
}
for(int i = 1; i <= 7; i ++)
cout << s[i] << endl;
}
int main()
{
int t;
cin >> t;
while(t --)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
YES #..# .##. #... #... .#.. #..# .##. YES ##.#. ..#.# .#... .#... .#... #.#.. .#.## NO YES .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### YES ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 44ms
memory: 3668kb
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: 31ms
memory: 3672kb
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: 3588kb
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: 40ms
memory: 3656kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
NO YES ###... ...### ..#... .#.... .#.... ..##.# ##..#. YES .#.###### #.#...... .#....... #........ #........ .#.##.... #.#..#### YES ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 6ms
memory: 4260kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
YES ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 9ms
memory: 4236kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
YES ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.