QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#739727 | #9621. 连方 | liubw_ | AC ✓ | 17ms | 6900kb | C++11 | 2.1kb | 2024-11-12 22:52:01 | 2024-11-12 22:52:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+10;
int a[10][N],n;
void print(){
for(int i=1;i<=7;i++){
for(int j=1;j<=n;j++) cout<<".#"[a[i][j]];
cout<<'\n';
}
}
void slv(){
cin>>n;
for(int i=1;i<=7;i++)
for(int j=0;j<=n+1;j++) a[i][j]=0;
int cnt1=0,cnt2=0;
string s;
cin>>s;
for(int i=1;i<=n;i++) if(s[i-1]=='#') a[1][i]=1,cnt1++;
cin>>s;
for(int i=1;i<=n;i++) if(s[i-1]=='#') a[7][i]=1,cnt2++;
// if( (cnt1==n&&cnt2!=n) || (cnt1!=n&&cnt2==n) ){
// cout<<"No\n";
// return;
// }
if(cnt1==n&&cnt2==n){
cout<<"Yes\n";
for(int i=1;i<=7;i++){
for(int j=1;j<=n;j++) cout<<'#';
cout<<'\n';
}
return;
}
for(int i=1;i<=n;i++){
if(i==1||a[2][i-1]==1||a[1][i-1]==1) a[2][i]=1;
if(a[1][i]==1) a[2][i]=0;
}
for(int i=1;i<=n;i++){
if(i==1||a[6][i-1]==1||a[7][i-1]==1) a[6][i]=1;
if(a[7][i]==1) a[6][i]=0;
}
// print();
if(cnt1==0||cnt2==0){
cout<<"Yes\n";
print();
return;
}
int ip1=-1,ip2=-1;
for(int i=1;i<=n;i++) if(a[2][i]==0&&(a[2][i-1]==1||a[2][i+1]==1)){
ip1=i;
a[3][ip1]=1;
break;
}
for(int i=1;i<=n;i++) if(a[6][i]==0&&(a[6][i-1]==1||a[6][i+1]==1)){
ip2=i;
a[5][ip2]=1;
break;
}
// assert((ip1>0&&ip2>0));
if(ip1<=0||ip2<=0){
// cerr<<"ip="<<ip1<<','<<ip2<<'\n';
cout<<"No\n";
return;
}
if(ip1>ip2) swap(ip1,ip2);
if(ip1==ip2||ip1+1==ip2){
a[4][ip1]=1;
}
else{
for(int i=ip1+1;i<ip2;i++) a[4][i]=1;
}
cout<<"Yes\n";
print();
return;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int T;
cin>>T;
while(T--) slv();
return 0;
}
/*
4
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
1
3
##.
.##
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5612kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 14ms
memory: 5760kb
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: 5932kb
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: 5688kb
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: 5924kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... .#.... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... #........ #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 17ms
memory: 6900kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 15ms
memory: 6492kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.