QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#742304 | #9621. 连方 | TauLee01# | AC ✓ | 16ms | 4220kb | C++17 | 2.9kb | 2024-11-13 16:19:42 | 2024-11-13 16:19:43 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
void solve() {
int n;
cin >> n;
string a, b;
cin >> a >> b;
if (count(a.begin(), a.end(), '#') == n && count(b.begin(), b.end(), '#') != n) {
cout << "No" << endl;
return;
}
if (count(a.begin(), a.end(), '#') != n && count(b.begin(), b.end(), '#') == n) {
cout << "No" << endl;
return;
}
if (count(a.begin(), a.end(), '#') == n && count(b.begin(), b.end(), '#') == n) {
cout << "Yes" << endl;
for (int i = 1; i <= 7; ++i) {
cout << a << endl;
}
return ;
}
vector<vector<char>>v(7, vector<char>(n));
int p1 = -1, p2 = -1;
for (int i = 0; i < n; ++i) {
v[0][i]=a[i];
if (v[0][i] == '.') {
v[1][i] = '#';
}
else{
v[1][i]='.';
if(p1==-1&&((i-1>=0&&a[i-1]=='.')||(i+1<n&&a[i+1]=='.'))){
p1=i;
}
}
v[6][i]=b[i];
if (v[6][i] == '.') {
v[5][i] = '#';
}
else{
v[5][i]='.';
// cout<<i<<" "<<p2<<endl;
if(p2==-1&&((i-1>=0&&b[i-1]=='.')||(i+1<n&&b[i+1]=='.'))){
p2=i;
}
}
// cout<<v[6][i];
}
// cout<<endl;
// cout<<p1<<" "<<p2<<endl;
if(p2==-1&&p1==-1){
cout << "Yes" << endl;
for (int i = 1; i <= 7; ++i) {
cout << a << endl;
}
return ;
}
else if(p1==-1){
cout << "Yes" << endl;
for (int i = 1; i <= 5; ++i) {
cout << a << endl;
}
for(int i=5;i<=6;++i){
for(int j=0;j<n;++j){
cout<<v[i][j];
}
cout<<endl;
}
return ;
}
else if(p2==-1){
cout << "Yes" << endl;
for(int i=0;i<=1;++i){
for(int j=0;j<n;++j){
cout<<v[i][j];
}
cout<<endl;
}
for (int i = 1; i <= 5; ++i) {
cout << b << endl;
}
return ;
}
else{
cout<<"Yes"<<endl;
for(int i=0;i<=n;++i){
v[2][i]='.';
v[3][i]='.';
v[4][i]='.';
}
v[2][p1]='#';
v[4][p2]='#';
if(p1==p2||p1==p2-1||p1==p2+1){
v[3][p1]='#';
}
else{
for(int i=min(p1,p2)+1;i<=max(p1,p2)-1;++i){
v[3][i]='#';
}
}
for(int i=0;i<=6;++i){
for(int j=0;j<n;++j){
cout<<v[i][j];
}
cout<<endl;
}
}
}
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int _ = 1;
cin >> _;
while (_--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 16ms
memory: 3628kb
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: 3888kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 15ms
memory: 3640kb
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: 15ms
memory: 3692kb
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: 4220kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 13ms
memory: 4220kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.