QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#793851 | #9621. 连方 | FHQY | WA | 0ms | 3564kb | C++20 | 3.2kb | 2024-11-30 02:40:48 | 2024-11-30 02:40:48 |
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];
int op[2];
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;
}
bool check()
{
vector<pair<int,int> > p[2];
for(int k=0;k<2;k++)
{
for(int i=1;i<=n;i++)
{
if(c[op[k]][i]=='.')
{
if(!p[k].empty()&&(p[k].back()).second==i-1)
p[k][p[k].size()-1].second++;
else
p[k].push_back({i,i});
}
}
}
// cout<<"#0"<<endl;
// for(auto [l,r] : p[0])
// cout<<l<<" "<<r<<endl;
// cout<<"#1"<<endl;
// for(auto [l,r] : p[1])
// cout<<l<<" "<<r<<endl;
for(auto[t1,t2]: p[0])
{
int s1,s2;
if(p[1].back().second<t1||p[1].front().first>t2)
continue;
int l=0,r=p[1].size()-1;
while(l<r)
{
int mid=(l+r)>>1;
if(p[1][mid].second>=t1)
r=mid;
else
l=mid+1;
}
s1=l;
l=0,r=p[1].size()-1;
while(l<r)
{
int mid=(l+r+1)>>1;
if(p[1][mid].first<=t2)
l=mid;
else
r=mid-1;
}
s2=l;
for(int i=s1;i<=s2;i++)
{
int l1=max(p[1][i].first,t1),r1=min(p[1][i].second,t2);
if(t1==p[1][i].first&&t2==p[1][i].second)
{
for(int t=l1;t<=r1;t++)
{
for(int k=op[0]+1;k<op[1];k++)
c[k][t]='#';
}
pri();
return true;
}
if(l1==p[1][i].first&&r1==p[1][i].second)
{
for(int t=l1;t<=r1;t++)
c[op[1]-1][t]='#';
for(int t=t1;t<=t2;t++)
{
if(t<=r1&&t>=l1) continue;
for(int k=op[0]+1;k<op[1]-1;k++)
c[k][t]='#';
}
pri();
return true;
}
if(l1==t1&&r1==t2)
{
for(int t=l1;t<=r1;t++)
c[op[0]+1][t]='#';
for(int t=p[1][i].first;t<=p[1][i].second;t++)
{
if(t<=r1&&t>=l1) continue;
for(int k=op[0]+2;k<op[1];k++)
c[k][t]='#';
}
pri();
return true;
}
if((l1==p[1][i].first&&r1==t2)||(r1==p[1][i].second&&l1==t1))
{
for(int k=l1;k<=r1;k++)
{
for(int j=op[0]+1;j<op[1];j++)
c[j][k]='#';
}
pri();
return true;
}
}
}
return false;
}
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]=='#'?'.':'#');
}
op[0]=2,op[1]=6;
if(check())
return;
op[0]++;
for(int i=1;i<=n;i++)
c[3][i]=(c[2][i]=='#'?'.':'#');
// pri();
bool flag=check();
assert(flag);
return ;
}
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
.######.######.####.#.#####
.####...####..#.......#####
*/
/*
1
6
.####.
..##..
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3564kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #..# .##. .##. #..# .##. Yes ##.#. ..#.# #.... #.... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .....##.................... .....##.................... .####...................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
wrong answer Testcase 2: Connected condition failed.