QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#746413 | #9621. 连方 | guodong# | AC ✓ | 26ms | 3908kb | C++17 | 4.7kb | 2024-11-14 14:32:03 | 2024-11-14 14:32:03 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,f[5][5],l1,l2,r1,r2;
string a,b;
char st[10][N];
int main(){
int t;
cin>>t;
while(t--){
cin>>n;
cin>>a;
cin>>b;
f[1][1]=1,f[1][2]=1;
int flag=0;
for(int i=1; i<=n; i++){
if(a[i-1]=='.'){
f[1][1]=0;
if(flag==1)st[2][i]='#';
else st[2][i]='.';
}
if(a[i-1]=='#')f[1][2]=0,st[2][i]='.',flag=1;
}
f[2][1]=1,f[2][2]=1;
flag=0;
for(int i=1; i<=n; i++){
if(b[i-1]=='.'){
f[2][1]=0;
if(flag==1)st[6][i]='#';
else st[6][i]='.';
}
if(b[i-1]=='#')f[2][2]=0,st[6][i]='.',flag=1;
}
if(f[1][1]==1){
if(f[2][1]==1){
puts("Yes");
for(int i=1; i<=7; i++)cout<<a<<'\n';
continue;
}else if(f[2][2]==1){
puts("Yes");
cout<<a<<'\n';
for(int i=2; i<=7; i++)cout<<b<<'\n';
continue;
}
puts("No");
continue;
}else if(f[1][2]==1){
if(f[2][1]==1){
puts("Yes");
cout<<a<<'\n';
for(int i=2; i<=7; i++)cout<<b<<'\n';
continue;
}else if(f[2][2]==1){
puts("Yes");
for(int i=1; i<=7; i++)cout<<a<<'\n';
continue;
}
puts("Yes");
for(int i=1; i<=5; i++)cout<<a<<'\n';
for(int i=1; i<=n; i++)cout<<st[6][i];
cout<<'\n'<<b<<'\n';
continue;
}
if(f[2][1]==1){
puts("No");
continue;
}else if(f[2][2]==1){
cout<<a<<'\n';
for(int i=1; i<=n; i++)cout<<st[2][i];
cout<<'\n';
for(int i=3; i<=7; i++)cout<<b<<'\n';
continue;
}
flag=0;
for(int i=1; i<=n; i++){
if(st[2][i]=='#'){
if(flag==0)l1=i;
flag=1;
r1=i;
}else{
if(flag==1)break;
}
}
if(flag==0){
for(int i=1; i<=n; i++)st[2][i]=a[i-1];
for(int i=1; i<=n; i++){
if(st[2][i]=='#'){
if(flag==0)l1=i;
flag=1;
r1=i;
}else{
if(flag==1)break;
}
}
}
flag=0;
for(int i=1; i<=n; i++){
if(st[6][i]=='#'){
if(flag==0)l2=i;
flag=1;
r2=i;
}else{
if(flag==1)break;
}
}
if(flag==0){
for(int i=1; i<=n; i++)st[6][i]=b[i-1];
for(int i=1; i<=n; i++){
if(st[6][i]=='#'){
if(flag==0)l2=i;
flag=1;
r2=i;
}else{
if(flag==1)break;
}
}
}
puts("Yes");
if(l1==l2){
cout<<a<<'\n';
for(int i=1; i<=n; i++)cout<<st[2][i];
cout<<'\n';
for(int i=3; i<=5; i++){
for(int j=1; j<=n; j++)if(j<l1)cout<<'#';else cout<<'.';
cout<<'\n';
}
for(int i=1; i<=n; i++)cout<<st[6][i];
cout<<'\n';
cout<<b<<'\n';
}else{
if(l1<l2){
cout<<a<<'\n';
for(int i=1; i<=n; i++)cout<<st[2][i];
cout<<'\n';
for(int i=3; i<=4; i++){
for(int j=1; j<=n; j++)if(j<l1)cout<<'#';else cout<<'.';
cout<<'\n';
}
for(int j=1; j<=n; j++)if(j>=l1&&j<l2)cout<<'#';else cout<<'.';
cout<<'\n';
for(int i=1; i<=n; i++)cout<<st[6][i];
cout<<'\n';
cout<<b<<'\n';
}else{
cout<<a<<'\n';
for(int i=1; i<=n; i++)cout<<st[2][i];
cout<<'\n';
for(int j=1; j<=n; j++)if(j<l1&&j>=l2)cout<<'#';else cout<<'.';
cout<<'\n';
for(int i=4; i<=5; i++){
for(int j=1; j<=n; j++)if(j<l2)cout<<'#';else cout<<'.';
cout<<'\n';
}
for(int i=1; i<=n; i++)cout<<st[6][i];
cout<<'\n';
cout<<b<<'\n';
}
}
}
}
详细
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: 15ms
memory: 3568kb
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: 26ms
memory: 3628kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... #######.................................. #######.................................. .......#########......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 15ms
memory: 3724kb
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: 15ms
memory: 3676kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ##.... ##.... ..##.# ##..#. Yes .#.###### ..#...... .#....... #........ #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... ######........................................... ######.............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 12ms
memory: 3908kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 16ms
memory: 3856kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.