QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#737511 | #9621. 连方 | SSAABBEERR# | AC ✓ | 15ms | 4496kb | C++20 | 2.7kb | 2024-11-12 16:02:09 | 2024-11-12 16:02:09 |
Judging History
answer
#include<bits/stdc++.h>
#define lowbit(x) (x & (-x))
#define endl "\n"
#define ll long long
#define int long long
// #define ull unsigned long long
#define fi first
#define se second
using namespace std;
#define pii pair<int, int>
#define rep(i, a, b) for(int i = a; i <= b; i ++ )
#define pre(i, a, b) for(int i = a; i >= b; i -- )
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
mt19937_64 rnd(time(0));
const int N = 1e6 + 10;
int n, m;
string le;
string re;
string ans[10];
void solve()
{
cin>>n;
cin>>le>>re;
le=" "+le;
re=" "+re;
int op=0;
int f=1;
for(int i=1;i<=n;i++){
if(le[i]=='.'){
f=0;
break;
}
}
op+=f;
f=1;
for(int i=1;i<=n;i++){
if(re[i]=='.'){
f=0;
break;
}
}
op+=f;
if(op==1){
cout<<"No\n";
return;
}
cout<<"Yes\n";
if(op==2){
for(int i=1;i<=7;i++){
for(int j=1;j<=n;j++){
cout<<"#";
}
cout<<"\n";
}
return;
}
ans[1]=le;
ans[7]=re;
ans[2]=ans[4]=ans[5]=ans[6]=ans[3]=" ";
// cout<<ans[1]<<"++\n";
// cout<<ans[7]<<"---\n";
for(int i=1;i<=n;i++){
if(ans[1][i]=='.'){
ans[2]+='#';
}
else ans[2]+='.';
if(ans[7][i]=='.'){
ans[6]+='#';
}
else ans[6]+='.';
}
for(int i=1;i<=n;i++){
// ans[3][i]=ans[4][i]=ans[5][i]='.';
ans[3]+='.';
ans[4]+='.';
ans[5]+='.';
}
int id1,id2;
id1=id2=-1;
for(int i=1;i<=n;i++){
if(ans[2][i]=='.'){
if((i>1&&ans[2][i-1]=='#')||(i<n&&ans[2][i+1]=='#')){
id1=i;
}
}
if(ans[6][i]=='.'){
if((i>1&&ans[6][i-1]=='#')||(i<n&&ans[6][i+1]=='#')){
id2=i;
}
}
}
if(id2!=-1&&id1!=-1){
// cout<<id1<<" "<<id2<<"++\n";
ans[3][id1]='#';
ans[5][id2]='#';
if(id1>id2){
swap(id1,id2);
}
if(id1==id2||id1==id2-1){
ans[4][id1]='#';
}
else{
for(int i=id1+1;i<id2;i++){
ans[4][i]='#';
}
}
}
for(int i=1;i<=7;i++){
for(int j=1;j<=n;j++){
cout<<ans[i][j];
}
cout<<"\n";
}
}
signed main()
{
IOS;
int _;
_ = 1;
cin >> _;
while(_ -- )
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3660kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. ...# ..#. ..#. #..# .##. Yes ##.#. ..#.# ...#. ...#. ...#. #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... ......................#.... ......................#.... ......................#.... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 15ms
memory: 3780kb
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: 15ms
memory: 3856kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ................#........................ .................############............ .............................#........... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 11ms
memory: 4032kb
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: 3784kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ...#.. ....#. ..##.# ##..#. Yes .#.###### #.#...... ...#..... ....#.... .....#... .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .......#......................................... ........########...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 15ms
memory: 4444kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 7ms
memory: 4496kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.