QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#738518 | #9621. 连方 | Aderose_yr# | AC ✓ | 14ms | 6660kb | C++17 | 2.1kb | 2024-11-12 19:15:51 | 2024-11-12 19:15:58 |
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
##.
.##
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5680kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 11ms
memory: 5964kb
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: 14ms
memory: 5772kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 14ms
memory: 5740kb
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: 14ms
memory: 3856kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... .#.... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... #........ #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 14ms
memory: 6660kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 14ms
memory: 6416kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.