QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#760526 | #9621. 连方 | Afterlife# | AC ✓ | 14ms | 7960kb | C++20 | 1.7kb | 2024-11-18 17:21:26 | 2024-11-18 17:21:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 200020;
int n,a[3][N],b[3][N];
string s,t;
bool work(string s,int a[3][N]){
for(int i=1;i<=n;++i){
a[0][i]=s[i]=='#';
a[1][i]=a[0][i]^1;
a[2][i]=0;
}
if(a[1][1]){
if(a[1][2])a[1][1]=0;
a[2][1]=1;
}
else{
if(a[1][2])a[2][1]=1;
else{
int p=-1;
for(int i=3;i<=n;++i){
if(a[1][i]){
p=i;
break;
}
}
if(p==-1)return false;
for(int i=2;i<p;++i){
a[2][i]=1;
}
}
}
return true;
}
bool all(string s){
for(int i=1;i<=n;++i){
if(s[i]=='.')return false;
}
return true;
}
void Solve(){
cin>>n;
cin>>s>>t;
s=' '+s;
t=' '+t;
if(all(s)&&all(t)){
cout<<"Yes\n";
for(int i=0;i<7;++i){
for(int j=1;j<=n;++j)cout<<'#';
cout<<'\n';
}
return;
}
if(!work(s,a)){
cout<<"No\n";
return;
}
if(!work(t,b)){
cout<<"No\n";
return;
}
cout<<"Yes\n";
for(int i=0;i<3;++i){
for(int j=1;j<=n;++j){
cout<<(a[i][j]?'#':'.');
}
cout<<'\n';
}
cout<<'#';
for(int i=1;i<n;++i){
cout<<'.';
}
cout<<'\n';
for(int i=2;i>=0;--i){
for(int j=1;j<=n;++j){
cout<<(b[i][j]?'#':'.');
}
cout<<'\n';
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin>>T;
while(T--)Solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5512kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... #... #..# .##. Yes ##.#. ..#.# .#... #.... #.... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... #.......................... #.......................... #.......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 10ms
memory: 5784kb
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: 4ms
memory: 5716kb
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: 7960kb
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: 5716kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### .##... #..... .#.... ..##.# ##..#. Yes .#.###### #.#...... #........ #........ #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .#####........................................... #..................
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 12ms
memory: 7140kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 12ms
memory: 7160kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.