QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#765525 | #9621. 连方 | Heenpei# | AC ✓ | 14ms | 4540kb | C++23 | 3.2kb | 2024-11-20 14:33:19 | 2024-11-20 14:33:19 |
Judging History
answer
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define Int __int128
#define pb push_back
#define eb emplace_back
#define MAX_LOG 21
#define ff first
#define ss second
#define M (int)1e4+10
#define ull unsigned long long
#define MAX_LOG 21
//#define double long double
using namespace std;
const double PI=3.1415926535897932385;
const int IIMIN=-2147483648;
//const ll p=998244353;
const ll mod=998244353;
const int INF=0x3f3f3f3f;
typedef pair<ll,ll> PLL;
typedef pair<double,double>PFF;
ll gcd(ll a,ll b)
{
if(b) while((a%=b)&&(b%=a));
return a+b;
}//最大公约数函数
ll spid(ll a,ll b,ll p)
{
ll ans=1;
while(b)
{
if(b&1)ans=ans*a%p;
b>>=1;
a=a*a%p;
}
return ans;
}//快速幂函数
///小香猪的代码块·香香猪猪惹人怜~
///秋雨想睡觉
const ll N =1e5+10;
char s[10][N];
void solve()
{
ll n;cin>>n;
string a,b;cin>>a>>b;
ll cnt[3]={0};
for(auto i:a)cnt[1]+=(i=='#');
for(auto i:b)cnt[2]+=(i=='#');
if(cnt[1]==n&&cnt[2]==n)
{
cout<<"Yes\n";
for(int i=1;i<=7;i++)cout<<a<<'\n';
return;
}else if(cnt[1]==n||cnt[2]==n)
{
cout<<"No\n";
return;
}
for(int i=1;i<=7;i++)
{
if(i==1)
{
for(int j=1;j<=n;j++)
{
s[i][j]=a[j-1];
}
}else if(i==7)
{
for(int j=1;j<=n;j++)
{
s[i][j]=b[j-1];
}
}else
{
for(int j=1;j<=n;j++)
{
s[i][j]='.';
}
}
s[i][n+1]='#';
s[i][0]='#';
}
for(int i=1;i<=n;i++)
{
if(s[1][i]=='.')s[2][i]='#';
if(s[7][i]=='.')s[6][i]='#';
}
// cout<<'\n';
// for(int i=1;i<=7;i++)
// {
// for(int j=1;j<=n;j++)
// {
// cout<<s[i][j];
// }cout<<'\n';
// }cout<<'\n';
PLL up,down;
for(int i=1;i<=n;i++)
{
if(s[2][i]=='#'&&(s[2][i-1]!='#'||s[2][i+1]!='#'))
{
if(s[2][i-1]!='#')up={3,i-1};
else up={3,i+1};
}
if(s[6][i]=='#'&&(s[6][i-1]!='#'||s[6][i+1]!='#'))
{
if(s[6][i-1]!='#')down={5,i-1};
else down={5,i+1};
}
}
// cout<<up.ff<<' '<<up.ss<<'\n';
// cout<<down.ff<<' '<<down.ss<<'\n';
s[up.ff][up.ss]='#';
s[down.ff][down.ss]='#';
if(abs(up.ss-down.ss)<=1)
{
s[up.ff+1][up.ss]='#';
}else
{
for(int i=min(up.ss,down.ss)+1;i<=max(up.ss,down.ss)-1;i++)
s[4][i]='#';
}
cout<<"Yes\n";
for(int i=1;i<=7;i++)
{
for(int j=1;j<=n;j++)
{
cout<<s[i][j];
}cout<<'\n';
}
}
//4
//4
//#..#
//.##.
//5
//##.#.
//.#.##
//6
//######
//.####.
//27
//.######.######.####.#.#####
//.####...####..#.......#####
///秋雨睡觉了
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t=1;
cin>>t;
while(t--)
{
solve();
}
}
///记忆是梦的开场白
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3672kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. ...# ...# ..#. #..# .##. Yes ##.#. ..#.# ...#. ..#.. .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... ....................#...... .....................#..... ......................#.... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 13ms
memory: 3640kb
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: 13ms
memory: 3636kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ..............#.......................... ...............############.............. ...........................#............. ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 9ms
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: 10ms
memory: 3932kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ...#.. ....#. ..##.# ##..#. Yes .#.###### #.#...... .#....... ..###.... .....#... .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......##########...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 10ms
memory: 4540kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 14ms
memory: 4536kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.