QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#737863 | #9621. 连方 | MEshooter | AC ✓ | 8ms | 4524kb | C++20 | 1.7kb | 2024-11-12 17:01:08 | 2024-11-12 17:01:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
char s[7][N];
int n;
int judge(){
int cnt = 2;
for(int i = 0; i < n; i++)
if(s[0][i] == '.') {cnt--; break;}
for(int i = 0; i < n; i++)
if(s[6][i] == '.') {cnt--; break;}
return cnt;
}
int main(){
int T; scanf("%d", &T);
while(T--){
scanf("%d%s%s", &n, s[0], s[6]);
if(judge() != 1){
printf("Yes\n");
if(judge() == 2){
for(int i = 0; i < 7; i++) printf("%s\n", s[0]);
continue;
}
}
else {printf("No\n"); continue;}
for(int i = 0; i < n; i++){
if(s[0][i] == '#') s[1][i] = '.';
else s[1][i] = '#';
if(s[6][i] == '#') s[5][i] = '.';
else s[5][i] = '#';
}
for(int i = 0; i < n; i++)
s[2][i] = s[4][i] = '.';
int pos1, pos2;
for(int i = 0; i < n; i++) if(s[1][i] == '.'){
if(i > 0 && s[1][i-1] == '#') {s[2][i] = '#'; pos1 = i; break;}
if(i < n-1 && s[1][i+1] == '#') {s[2][i] = '#'; pos1 = i; break;}
}
for(int i = n-1; i >= 0; i--) if(s[5][i] == '.'){
if(i > 0 && s[5][i-1] == '#') {s[4][i] = '#'; pos2 = i; break;}
if(i < n-1 && s[5][i+1] == '#') {s[4][i] = '#'; pos2 = i; break;}
}
if(abs(pos1-pos2) == 1) strcpy(s[3], s[2]), strcpy(s[2], s[1]);
else for(int i = 0; i < n; i++)
if(s[2][i] == '#' || s[4][i] == '#') s[3][i] = '.';
else s[3][i] = '#';
for(int i = 0; i < 7; i++)
printf("%s\n", s[i]);
for(int i = 0; i < 7; i++)
memset(s[i], 0, n+1);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3872kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... .#.# ..#. #..# .##. Yes ##.#. ..#.# .#... #.#.# ...#. #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... #.####################.#### ......................#.... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 7ms
memory: 3904kb
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: 7ms
memory: 3832kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. ######.######################.########### .............................#........... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 7ms
memory: 3816kb
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: 8ms
memory: 3828kb
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: 4488kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 3ms
memory: 4524kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.