QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#739082 | #9621. 连方 | fengjiuge | AC ✓ | 28ms | 4744kb | C++14 | 1.3kb | 2024-11-12 20:47:54 | 2024-11-12 20:47:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
string ans[8];
void solve(){
int n;cin>>n;
string fa,fb,a,b;cin>>a>>b;
ans[1]=a;
ans[7]=b;
for(auto i:a){
if(i=='.')fa+='#';
else fa+='.';
}
for(auto i:b){
if(i=='.')fb+='#';
else fb+='.';
}
string std1(n,'#');
if(std1==a&&std1!=b||std1==b&&std1!=a){
cout<<"No"<<endl;
return ;
}
if(std1==a&&std1==b){
cout<<"Yes"<<endl;
for(int i=1;i<=7;i++){
cout<<std1<<endl;
}
return;
}
ans[2]=fa;
ans[6]=fb;
// cout<<n<<endl;
string ss(n,'.');
string s1=ss;
// cout<<s1<<endl;
ans[3]=s1;
// cout<<ans[3]<<endl;
int pos1=0,pos2=0;
for(int i=0;i<n;i++){
if(((i>0&&ans[2][i-1]=='#')||(i<n-1&&ans[2][i+1]=='#'))&&ans[2][i]=='.'){
ans[3][i]='#';
pos1=i;break;
}
}
// cout<<ans[3]<<endl;
ans[5]=s1;
for(int i=0;i<n;i++){
if(((i>0&&ans[6][i-1]=='#')||(i<n-1&&ans[6][i+1]=='#'))&&ans[6][i]=='.'){
ans[5][i]='#';
pos2=i;break;
}
}
ans[4]=s1;
if(pos1==pos2){
ans[4][pos1]='#';
}else if(abs(pos1-pos2)==1){
ans[4][pos1]='#';
}else{
int min1=min(pos1,pos2);
int max1=max(pos1,pos2);
for(int i=min1+1;i<max1;i++){
ans[4][i]='#';
}
}cout<<"Yes"<<endl;
for(int i=1;i<=7;i++){
cout<<ans[i]<<endl;
}
}
signed main(){
int t;cin>>t;
while(t--)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 16ms
memory: 3656kb
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: 28ms
memory: 3708kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 28ms
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: 28ms
memory: 3708kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ..#... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... .#....... #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 8ms
memory: 4744kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 8ms
memory: 4676kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.