QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#793525 | #9621. 连方 | FHQY | WA | 0ms | 3616kb | C++20 | 1.9kb | 2024-11-29 20:47:49 | 2024-11-29 20:47:50 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define endl '\n'
using namespace std;
const int N=1e5+5;
int n;
string a,b;
char c[10][N];
void pri()
{
cout<<"Yes"<<endl;
for(int i=1;i<=7;i++)
{
for(int j=1;j<=n;j++)
cout<<c[i][j];
cout<<endl;
}
return;
}
void solve(){
cin>>n>>a>>b;
int c1=0,c2=0;
for(int i=1;i<=7;i++)
for(int j=1;j<=n;j++)
c[i][j]='.';
for(int i=1;i<=n;i++)
c1+=(a[i-1]=='#'),c2+=(b[i-1]=='#');
if(c1==n||c2==n){
if(c1==n&&c2==n){
cout<<"Yes"<<endl;
for(int i=1;i<=7;i++){
for(int j=1;j<=n;j++)
cout<<'#';
cout<<endl;
}
}else cout<<"No"<<endl;
return;
}
for(int i=1;i<=n;i++)c[1][i]=a[i-1];
for(int i=1;i<=n;i++)c[7][i]=b[i-1];
for(int i=1;i<=n;i++){
c[2][i]=(c[1][i]=='#'?'.':'#');
c[6][i]=(c[7][i]=='#'?'.':'#');
c[3][i]=c[1][i];
c[5][i]=c[7][i];
}
for(int i=1;i<=n;i++)
{
if(c[3][i]==c[5][i]&&c[3][i]=='#')
{
c[4][i]='#';
if((i+1<=n&&c[3][i+1]=='#')||(i-1>=1&&c[3][i-1]=='#'))
c[3][i]='.';
if((i+1<=n&&c[5][i+1]=='#')||(i-1>=1&&c[5][i-1]=='#'))
c[5][i]='.';
pri();
return;
}
}
bool flag=0;
for(int i=1;i<=n;i++)
{
if(c[3][i]==c[5][i]&&c[3][i]=='.')
{
c[4][i]='#';
}
}
for(int i=1;i<=n;)
{
if(c[4][i]=='.')
{
i++;
continue;
}
int r=i;
while(r<=n&&c[4][r]=='#')
r++;
if(i-1>=1&&r<=n&&((c[3][i-1]=='#'&&c[5][r]=='#')||(c[5][i-1]=='#'&&c[3][r]=='#')))
flag=1;
i=r;
}
if(flag)
{
pri();
return;
}
for(int i=1;i<=n;i++)
{
c[4][i]=c[3][i];
}
pri();
}
int T=1;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>T;
for(int kase=1;kase<=T;kase++){
solve();
}
return 0;
}
/*
4
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3616kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #..# #..# .##. #..# .##. Yes ##.#. ..#.# #..#. .#... .#.## #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... ..#####.######.####.#.##### .#......................... ..###...####..#.......##### #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
wrong answer Testcase 2: Connected condition failed.