QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#739719 | #9621. 连方 | xly_tyty# | AC ✓ | 7ms | 4740kb | C++23 | 1.6kb | 2024-11-12 22:48:40 | 2024-11-12 22:48:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+10,mod=998244353;
string ans[7];
void solve() {
int n; cin >> n;
string a, b;
cin >> a >> b;
for (int i = 1; i <= 5; i ++ ) {
ans[i].clear();
ans[i] = a;
}
if (a == b&&a==string(n,'#')) {
cout<<"Yes"<<'\n';
for (int i = 0; i < 7; i ++) {
cout << a << '\n';
}
return ;
}
if (a == string(n, '#') || b == string(n, '#') ) {
cout << "No" << '\n';
return ;
}
cout << "Yes\n";
for (int i = 0; i < n; i ++ ) {
if ( a[i] == '#' ) {
ans[1][i] = '.';
} else {
ans[1][i] = '#';
}
}
for (int i = 0; i < n; i ++ ) {
if ( b[i] == '#' ) {
ans[5][i] = '.';
} else {
ans[5][i] = '#';
}
}
int id1 = 0;
int id2 = 0;
ans[2] = string(n, '.');
for(int i = 0; i < n; i ++ ) {
if ( ans[1][i] == '.' && ((i+1<n&&ans[1][i + 1] == '#')||(i-1>=0&&ans[1][i-1]=='#'))) {
ans[2][i] = '#';
id1 = i;
break ;
}
}
ans[4] = string(n, '.');
for(int i = 0; i < n; i ++ ){
if ( ans[5][i] == '.' && ((i+1<n&&ans[5][i + 1] == '#')||(i-1>=0&&ans[5][i-1]=='#')) ) {
ans[4][i] = '#';
id2 = i;
break ;
}
}
ans[3] = string(n, '.');
if(id1>id2)swap(id1,id2);
if(id2-id1<=1)
{
ans[3][id2]='#';
}
for (int i = id1+1; i < id2; i ++ ) {
ans[3][i] = '#';
}
ans[0] = a;
ans[6] = b;
for ( int i = 0; i < 7; i ++) {
cout << ans[i] << '\n';
}
// cout << '\n';
return ;
}
int main(void) {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int t= 1;
cin >> t ;
while(t -- ) {
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... .#.. .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 6ms
memory: 3656kb
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: 3ms
memory: 3900kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 6ms
memory: 3660kb
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: 7ms
memory: 3872kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ..#... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... .#....... #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 0ms
memory: 4740kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 2ms
memory: 4540kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.