QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#762781 | #9621. 连方 | xdz_ | AC ✓ | 29ms | 10060kb | C++14 | 1.7kb | 2024-11-19 16:37:28 | 2024-11-19 16:37:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define se second
#define fi first
#define endl '\n'
const int N = 1e5 + 10;
int a[10][N];
void solve(){
int n;
cin>>n;
for(int i = 1; i <= 7;i ++){
for(int j = 0;j <= n + 1;j ++) a[i][j] = 0;
}
string s1,s2;
cin>>s1>>s2;
int p1 = 0,p2 = 0;
s1 = " " + s1;
s2 = " " + s2;
for(int i = 1;i <= n;i ++){
if(s1[i] == '.'){
p1 = 1;
a[1][i] = 0;
}
else a[1][i] = 1;
if(s2[i] == '.') {
p2 = 1;
a[7][i] = 0;
}
else a[7][i] = 1;
}
if(p1 == 0 && p2 == 0){
cout<<"Yes"<<endl;
for(int i = 1;i <= 7;i ++){
for(int j = 1;j <= n;j ++) cout<<"#";
cout<<endl;
}
return ;
}
if(p1 == 0 || p2 == 0){
cout<<"No"<<endl;
return ;
}
for(int i = 1;i <= n;i ++) {
if(a[1][i] == 0) a[2][i] = 1;
if(a[7][i] == 0) a[6][i] = 1;
}
int pos1 = 0,pos2 = 0;
for(int i = 1;i <= n;i ++){
if(a[2][i] == 0 && (a[2][i - 1] == 1 || a[2][i + 1] == 1)){
a[3][i] = 1;
pos1 = i;
break;
}
}
for(int i = 1;i <= n;i ++){
if(a[6][i] == 0 && (a[6][i - 1] == 1 || a[6][i + 1] == 1) ){
a[5][i] = 1;
pos2 = i;
break;
}
}
// cout<<pos1<<" "<<pos2<<endl;
if(pos1 > pos2) swap(pos1,pos2);
if(pos1 == pos2){
a[4][pos1] = 1;
}
else if(pos1 + 1 == pos2){
a[4][pos1] = 1;
}
else{
for(int i = min(pos1,pos2) + 1;i < max(pos1,pos2);i ++){
a[4][i] = 1;
}
}
cout<<"Yes"<<endl;
for(int i = 1; i <= 7;i ++){
for(int j = 1;j <= n;j ++) {
if(a[i][j] == 0) cout<<".";
else cout<<"#";
}
cout<<endl;
}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7692kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 27ms
memory: 9740kb
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: 19ms
memory: 7860kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 28ms
memory: 10040kb
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: 29ms
memory: 9688kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... .#.... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... #........ #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 29ms
memory: 10056kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 28ms
memory: 10060kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.