QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#736352 | #9621. 连方 | OIer_kzc# | AC ✓ | 7ms | 1668kb | C++17 | 1.8kb | 2024-11-12 10:18:10 | 2024-11-12 10:18:16 |
Judging History
answer
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <algorithm>
#define LOG(FMT...) fprintf(stderr, FMT)
using namespace std;
typedef long double LDB;
typedef long long LL;
constexpr int N = 100005;
constexpr int mod = 998244353;
int n;
char a[N], b[N];
void simp(char *a) {
for (int i = 0; i < n; ++i) {
a[i] = (a[i] == '#');
}
}
bool chkAll(char *a) {
for (int i = 0; i < n; ++i) {
if (!a[i]) {
return false;
}
}
return true;
}
int getp(char *a) {
for (int i = 1; i < n; ++i) {
if (a[i] != a[i - 1]) {
if (a[i]) {
return i;
}
return i - 1;
}
}
assert(0);
}
void outline(int x, int y) {
if (x > y) {
swap(x, y);
}
if (y - x < 2) {
for (int i = 0; i < n; ++i) {
putchar(".#"[i == x]);
}
} else {
for (int i = 0; i < n; ++i) {
putchar(".#"[x < i && i < y]);
}
}
puts("");
}
void solve() {
scanf("%d%s%s", &n, a, b);
simp(a), simp(b);
bool fa = chkAll(a), fb = chkAll(b);
if (fa && fb) {
puts("Yes");
for (int i = 0; i < 7; ++i) {
for (int j = 0; j < n; ++j) {
putchar('#');
}
puts("");
}
return;
}
if (fa || fb) {
puts("No");
return;
}
puts("Yes");
for (int i = 0; i < n; ++i) {
putchar(".#"[a[i]]);
}
puts("");
for (int i = 0; i < n; ++i) {
putchar(".#"[!a[i]]);
}
puts("");
int pa = getp(a), pb = getp(b);
for (int i = 0; i < n; ++i) {
putchar(".#"[i == pa]);
}
puts("");
outline(pa, pb);
for (int i = 0; i < n; ++i) {
putchar(".#"[i == pb]);
}
puts("");
for (int i = 0; i < n; ++i) {
putchar(".#"[!b[i]]);
}
puts("");
for (int i = 0; i < n; ++i) {
putchar(".#"[b[i]]);
}
puts("");
}
int main() {
int task;
for (scanf("%d", &task); task--; ) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 1552kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 7ms
memory: 1416kb
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: 1556kb
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: 1460kb
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: 1412kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... .#.... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... #........ #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 2ms
memory: 1660kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 0ms
memory: 1668kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.