QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#767415 | #9621. 连方 | OOBMABTRAMS# | AC ✓ | 20ms | 4052kb | C++17 | 1.2kb | 2024-11-20 20:53:20 | 2024-11-20 20:53:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int N=1000013;
typedef long long ll;
typedef long double ld;
string s[10];
const char v='#'^'.';
void solve(){
int n;cin>>n;
cin>>s[1]>>s[7];
s[2]=s[1];
int c1=0;
for(int i=0;i<n;i++)s[2][i]^=v,c1+=s[2][i]=='#';
s[6]=s[7];
int c2=0;
for(int i=0;i<n;i++)s[6][i]^=v,c2+=s[6][i]=='#';
if(c1==0&&c2==0){
cout<<"Yes\n";
for(int i=1;i<=7;i++)cout<<s[1]<<'\n';
return;
}
if(c1==0||c2==0) {
cout<<"No\n";
return;
}
cout<<"Yes\n";
c1=c2=-1;
for(int i=0;i+1<n;i++)if(s[2][i]=='.'&&s[2][i+1]=='#')c1=i;
for(int i=0;i+1<n;i++)if(s[6][i]=='.'&&s[6][i+1]=='#')c2=i;
for(int i=1;i<n;i++)if(s[2][i]=='.'&&s[2][i-1]=='#')c1=i;
for(int i=1;i<n;i++)if(s[6][i]=='.'&&s[6][i-1]=='#')c2=i;
s[3]=s[5]=s[4]="";
for(int i=0;i<n;i++)s[3]+='.',s[5]+='.',s[4]+='.';
s[3][c1]=s[5][c2]='#';
if(c1>c2)swap(c1,c2);
if(c2-c1<=1) {
s[4][c1]='#';
}else {
for(int i=c1+1;i<c2;i++)s[4][i]='#';
}
for(int i=1;i<=7;i++)cout<<s[i]<<'\n';
}
//
signed main(){
int T=1;cin>>T;
while(T--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. ...# ..#. .#.. #..# .##. Yes ##.#. ..#.# ...#. ...#. ...#. #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... ......................#.... ......................#.... ......................#.... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 4ms
memory: 3700kb
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: 17ms
memory: 3728kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ................#........................ .................############............ .............................#........... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 20ms
memory: 3764kb
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: 3780kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ...#.. ....#. ..##.# ##..#. Yes .#.###### #.#...... ...#..... ....#.... .....#... .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .......#......................................... ........########...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 3ms
memory: 3976kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 10ms
memory: 4052kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.