QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#746390 | #9621. 连方 | OQYoqy | AC ✓ | 42ms | 9828kb | C++20 | 4.8kb | 2024-11-14 14:28:41 | 2024-11-14 14:28:41 |
Judging History
answer
#include<stdio.h>
#include<iostream>
#include<algorithm>
#define inf 0X7fffffff
using namespace std;
const int N=2e5+9;
int read(int &x){
int dat=0,oko=1;char chc=getchar();
while(chc<'0'||chc>'9'){if(chc=='-')oko=-1;chc=getchar();}
while(chc>='0'&&chc<='9'){dat=dat*10+chc-'0';chc=getchar();}
x=dat*oko;return x;
}int n,a[8][N],n1,n2,tip,f1,f2,ca,tt,mxx;
//char s1[N],s2[N];
string s1,s2;
void solve(){
//n=8;
cin>>n>>s1>>s2;
if(!mxx)mxx=n;
// if(tt==10000&&mxx==41){
// if(++ca==9099){
// cout<<s1<<"\n"<<s2<<"\n";
// }else return;
// }
n1=0,n2=0;f1=0;f2=0;
//cout<<"ASLDKJ\n";
for(int i=1;i<=n;i++){
for(int j=1;j<=7;j++){
a[j][i]=0;
}
}//cout<<"FLaskljd\n";
for(int i=0;i<n;i++){
// if(rand()&1)s1[i]='#';
// else s1[i]='.';
// if(rand()&1)s2[i]='#';
// else s2[i]='.';
if(s1[i]=='#'){
a[1][i+1]=1;n1++;
}if(s1[i]=='.'){
a[1][i+1]=0;
}if(s2[i]=='#'){
a[7][i+1]=1;n2++;
}if(s2[i]=='.'){
a[7][i+1]=0;
}
}if(n1==n&&n2==n){
cout<<"Yes\n";
for(int i=1;i<=7;i++){
for(int j=1;j<=n;j++){
cout<<"#";
}cout<<"\n";
}return;
}if(n1==n||n2==n){
if(!n1){
cout<<"Yes\n";
for(int j=1;j<=6;j++){
for(int i=1;i<=n;i++){
cout<<'.';
}cout<<"\n";
}for(int i=1;i<=n;i++){
cout<<'#';
}cout<<"\n";
return;
}if(!n2){
cout<<"Yes\n";
for(int i=1;i<=n;i++){
cout<<'#';
}cout<<"\n";
for(int j=1;j<=6;j++){
for(int i=1;i<=n;i++){
cout<<'.';
}cout<<"\n";
}return;
}
cout<<"No\n";
return;
}
cout<<"Yes\n";
for(int i=1;i<=n;i++){
if(a[1][i])continue;
if(i>1&&a[1][i-1]){
a[2][i]=1;
}if(i<n&&a[1][i+1]){
a[2][i]=1;
}
}for(int i=1;i<=n;i++){
if(a[2][i])continue;
if(i>1&&a[2][i-1])tip=i;
if(i<n&&a[2][i+1])tip=i;
}
a[3][tip]=1;
for(int i=1;i<=n;i++){
if(a[7][i])continue;
if(i>1&&a[7][i-1])a[6][i]=1;
if(i<n&&a[7][i+1])a[6][i]=1;
if(a[6][i]&&i==tip-1){f1=1;continue;}
if(a[6][i]&&i==tip+1){f2=1;continue;}
a[5][i]=a[6][i];
}
//printf("FF %d %d\n",f1,f2);
if(f1&&f2){
if(a[6][tip-1]&&a[6][tip-2]){
a[5][tip-2]=0;
}if(a[6][tip+1]&&a[6][tip+2]){
a[5][tip+2]=0;
}
a[5][tip]=1;
}if(f1){
if(a[6][tip]){
a[5][tip-2]=1;a[5][tip]=0;
for(int k=3;tip-k>=1;k++){
if(!a[5][tip-k])break;
a[5][tip-k]=0;
}
}else {
a[5][tip]=1;
for(int k=2;tip-k>=1;k++){
if(!a[5][tip-k])break;
a[5][tip-k]=0;
}
}
}if(f2){
if(a[6][tip]){
a[5][tip]=0;a[5][tip+2]=1;
for(int k=3;tip+k<=n;k++){
if(!a[5][tip+k])break;
a[5][tip+k]=0;
}
}else {
a[5][tip]=1;
for(int k=2;tip+k<=n;k++){
if(!a[5][tip+k])break;
a[5][tip+k]=0;
}
}
}for(int i=1;i<=n;i++){
if(a[1][i]||a[3][i])continue;
a[2][i]=1;
}for(int i=1;i<=n;i++){
if(a[1][i])cout<<"#";
else cout<<".";
}cout<<"\n";
for(int i=1;i<=n;i++){
if(a[2][i])cout<<"#";
else cout<<".";
}cout<<"\n";
for(int i=1;i<=n;i++){
if(a[3][i])cout<<"#";
else cout<<".";
}cout<<"\n";
for(int i=1;i<=n;i++){
if(!a[5][i]&&i!=tip)cout<<"#";
else cout<<".";
}cout<<"\n";
for(int i=1;i<=n;i++){
if(a[5][i])cout<<"#";
else cout<<".";
}cout<<"\n";
for(int i=1;i<=n;i++){
if(a[6][i])cout<<"#";
else cout<<".";
}cout<<"\n";
for(int i=1;i<=n;i++){
if(a[7][i])cout<<"#";
else cout<<".";
}cout<<"\n";
}
int main(){
srand(time(0));
int T;cin>>T;tt=T;
while(T--)solve();
return 0;
}
/*
4
8
....#.#.
..##..##
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.####...####..#.......#####
.######.######.####.#.#####
1
17
.#####.##########
#######..#..#####
1
41
########################.######..########
.#######..######.########################
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7800kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. ...# .##. #..# #..# .##. Yes ##.#. ..#.# ...#. .##.# #..#. #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... ......................#.... .####.#.####..#.######.#### #....#.#....##.#......#.... #....#.#....##.#.....#..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 32ms
memory: 7936kb
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: 41ms
memory: 9828kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ................#........................ ################.###.#######.############ ................#...#.......#............ ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 36ms
memory: 7840kb
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: 40ms
memory: 7868kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...#.# ....#. ####.# ....#. ..##.# ##..#. Yes .#.###### #.#...... ...#..... #.#.#.### .#...#... .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .......#......................................... #######.########...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 37ms
memory: 8704kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 42ms
memory: 8736kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.