QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#741194 | #9621. 连方 | ucup-team4479# | AC ✓ | 12ms | 4408kb | C++23 | 1.9kb | 2024-11-13 13:45:02 | 2024-11-13 13:45:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int T,n;
char a[8][200050];
int main() {
cin.tie(nullptr) -> ios::sync_with_stdio(false);
cout.tie(0);
cin>>T;
while(T--)
{
cin>>n;
cin>>a[1];
cin>>a[7];
int f1=1,f7=1;
for(int i=0;i<n;i++)if(a[1][i]=='.')f1=0;
for(int i=0;i<n;i++)if(a[7][i]=='.')f7=0;
if(f1+f7==1)
{
cout<<"No\n";
continue;
}
if(f1==1&&f7==1)
{
cout<<"Yes\n";
for(int i=1;i<=7;i++,cout<<'\n')
for(int j=0;j<n;j++)cout<<"#";
continue;
}
for(int i=0;i<n;i++)
{
if(a[1][i]=='.')a[2][i]='#';
else a[2][i]='.';
if(a[7][i]=='.')a[6][i]='#';
else a[6][i]='.';
}
for(int i=3;i<=5;i++)
for(int j=0;j<n;j++)a[i][j]='.';
int p3=0;
int p5=0;
for(int i=0;i<n;i++)
{
if(a[2][i]=='.'&&((i>0&&a[2][i-1]=='#')||(i+1<n&&a[2][i+1]=='#')))
{
a[3][i]='#';
p3=i;
break;
}
}
for(int i=0;i<n;i++)
{
if(a[6][i]=='.'&&((i>0&&a[6][i-1]=='#')||(i+1<n&&a[6][i+1]=='#')))
{
a[5][i]='#';
p5=i;
break;
}
}
if(p3>p5)swap(p3,p5);
if(p3==p5||p3+1==p5)
{
a[4][p3]='#';
}
else
{
for(int i=p3+1;i<p5;i++)a[4][i]='#';
}
cout<<"Yes\n";
for(int i=1;i<=7;i++,cout<<"\n")
for(int j=0;j<n;j++)cout<<a[i][j];
}
return 0;
}
/*
4
4
#..#
.##.
5
##.#.
.#.##
6
.#####
######
27
#######.######.####.#.#####
.####...####..#.......#####
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 12ms
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: 12ms
memory: 3664kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 12ms
memory: 3656kb
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: 9ms
memory: 3720kb
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: 4408kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 7ms
memory: 4400kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.