QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#739713 | #9621. 连方 | peiyangwjx | AC ✓ | 21ms | 4544kb | C++20 | 2.1kb | 2024-11-12 22:47:30 | 2024-11-12 22:47:34 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
char s[10][200010];
int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
scanf("%s",s[1]);
scanf("%s",s[7]);
int yi=0,er=0;
for(int i=0;i<n;i++){
if(s[1][i]=='.')yi=1;
if(s[7][i]=='.')er=1;
}
if(yi==0&&er==0){
cout<<"Yes"<<'\n';
for(int i=1;i<=7;i++){
for(int j=0;j<n;j++){
cout<<s[1][j];
}
cout<<'\n';
}
continue;
}
if(yi==0||er==0){
cout<<"No"<<'\n';
continue;
}
for(int i=0;i<n;i++){
if(s[1][i]=='.')s[2][i]='#';
else s[2][i]='.';
if(s[7][i]=='.')s[6][i]='#';
else s[6][i]='.';
}
int pos3=0,pos5=0;
if(s[2][0]=='.'&&s[2][1]=='#')pos3=0;
if(s[2][n-1]=='.'&&s[2][n-2]=='#')pos3=n-1;
if(s[6][0]=='.'&&s[6][1]=='#')pos5=0;
if(s[6][n-1]=='.'&&s[6][n-2]=='#')pos5=n-1;
for(int i=1;i<n-1;i++){
if(s[2][i]=='.'&&(s[2][i+1]=='#'||s[2][i-1]=='#'))pos3=i;
if(s[6][i]=='.'&&(s[6][i+1]=='#'||s[6][i-1]=='#'))pos5=i;
}
for(int i=0;i<n;i++){
if(i==pos3)s[3][i]='#';
else s[3][i]='.';
if(i==pos5)s[5][i]='#';
else s[5][i]='.';
}
if(pos3==pos5){
for(int i=0;i<n;i++){
if(i==pos3)s[4][i]='#';
else s[4][i]='.';
}
}else if(abs(pos3-pos5)==1){
for(int i=0;i<n;i++){
if(i==pos3)s[4][i]='#';
else s[4][i]='.';
}
}else{
for(int i=0;i<n;i++){
if(i<max(pos3,pos5)&&i>min(pos3,pos5))s[4][i]='#';
else s[4][i]='.';
}
}
cout<<"Yes"<<'\n';
for(int i=1;i<=7;i++){
for(int j=0;j<n;j++){
cout<<s[i][j];
}
cout<<'\n';
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3868kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. ...# ...# ..#. #..# .##. Yes ##.#. ..#.# ...#. ...#. ...#. #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... ......................#.... ......................#.... ......................#.... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 14ms
memory: 3852kb
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: 21ms
memory: 3720kb
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: 3848kb
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: 17ms
memory: 3848kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ...#.. ....#. ..##.# ##..#. Yes .#.###### #.#...... ...#..... ....#.... .....#... .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .......#......................................... ........########...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 16ms
memory: 4544kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 13ms
memory: 4344kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.