QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#736847 | #9621. 连方 | hezlik# | AC ✓ | 12ms | 4332kb | C++20 | 2.1kb | 2024-11-12 13:39:50 | 2024-11-12 13:39:51 |
Judging History
answer
#include <bits/stdc++.h>
typedef long long int64;
int n;
std::string a,b;
void work(){
std::cin>>n>>a>>b;
std::vector<int> p,q;
for (int i=0;i<n;++i){
if (a[i]=='.') p.push_back(i);
if (b[i]=='.') q.push_back(i);
}
if (p.empty()&&q.empty()){
std::cout<<"Yes\n";
for (int i=0;i<7;++i){
for (int j=0;j<n;++j)
std::cout<<'#';
std::cout<<'\n';
}
return;
}
if (p.empty()||q.empty()){
std::cout<<"No\n";
return;
}
std::cout<<"Yes\n";
if ((int)p.size()==n){
for (int i=0;i<5;++i){
for (int j=0;j<n;++j)
std::cout<<'.';
std::cout<<'\n';
}
for (int i=0;i<n;++i)
std::cout<<(b[i]=='.'?'#':'.');
std::cout<<b<<'\n';
return;
}
if ((int)q.size()==n){
std::cout<<a<<'\n';
for (int i=0;i<n;++i)
std::cout<<(a[i]=='.'?'#':'.');
for (int i=0;i<5;++i){
for (int j=0;j<n;++j)
std::cout<<'.';
std::cout<<'\n';
}
std::cout<<'\n';
return;
}
std::cout<<a<<'\n';
for (int i=0;i<n;++i)
std::cout<<(a[i]=='.'?'#':'.');
std::cout<<'\n';
int x=0;
for (int i=0;i<n;++i)
if (a[i]=='#'&&((i&&a[i-1]=='.')||(i+1<n&&a[i+1]=='.'))){
x=i;
break;
}
int y=0;
for (int i=0;i<n;++i)
if (b[i]=='#'&&((i&&b[i-1]=='.')||(i+1<n&&b[i+1]=='.'))){
y=i;
break;
}
for (int i=0;i<n;++i)
std::cout<<(i==x?'#':'.');
std::cout<<'\n';
int l=x,r=y;
if (l>r) std::swap(l,r);
if (l+1==r) --r;
if (l+1<r) ++l,--r;
for (int i=0;i<n;++i)
std::cout<<(i>=l&&i<=r?'#':'.');
std::cout<<'\n';
for (int i=0;i<n;++i)
std::cout<<(i==y?'#':'.');
std::cout<<'\n';
for (int i=0;i<n;++i)
std::cout<<(b[i]=='.'?'#':'.');
std::cout<<'\n';
std::cout<<b<<'\n';
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t=1;
std::cin >> t;
while (t--) {
work();
}
}
/*
4
4
.##.
#..#
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
*/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3848kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 12ms
memory: 3588kb
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: 8ms
memory: 3672kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 8ms
memory: 3620kb
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: 12ms
memory: 3584kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... .#.... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... #........ #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 10ms
memory: 4332kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 11ms
memory: 4284kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.