QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#750840 | #9621. 连方 | ucup-team3519# | AC ✓ | 12ms | 4688kb | C++17 | 1.9kb | 2024-11-15 16:06:19 | 2024-11-15 16:06:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define pb push_back
typedef long long LL;
const int mod = 998244353;
V<string> gen(string s) {
int n = s.size();
string p = s;
for(char &c : p) {
if(c == '.') c = '#';
else c = '.';
}
string q(n, '.');
q[0] = '#';
if(p[0] == p[1] && p[1] == '#') {
p[0] = '.';
} else if(p[0] == '#' && p[1] == '.') {
} else if(p[0] == '.' && p[1] == '#') {
} else if(p[0] == '.' && p[1] == '.') {
q[0] = '.';
int pos;
for(int i = 0; i < n; i++) {
if(p[i] == '#') {
pos = i;
break;
}
}
for(int i = 1; i < pos; i++) q[i] = '#';
}
return {s, p, q};
}
bool all_sharp(string s) {
bool ok = 1;
for(auto c : s) {
if(c != '#') ok = 0;
}
return ok;
}
bool all_dot(string s) {
bool ok = 1;
for(auto c : s) {
if(c != '.') ok = 0;
}
return ok;
}
void solve() {
int n; cin >> n;
string a, b; cin >> a >> b;
if(all_dot(a) && all_sharp(b) || all_dot(b) && all_sharp(a)) {
cout << "Yes" << "\n";
for(int i = 1; i <= 6; i++) cout << a << "\n";
cout << b << "\n";
return;
}
if(all_sharp(a) ^ all_sharp(b)) {
cout << "No" << "\n";
return;
}
cout << "Yes" << "\n";
if(all_sharp(a) && all_sharp(b)) {
for(int i = 1; i <= 7; i++) {
cout << a << "\n";
}
return;
}
auto va = gen(a), vb = gen(b);
for(int i = 0; i < 3; i++) cout << va[i] << "\n";
cout << "#";
for(int i = 2; i <= n; i++) cout << ".";
cout << "\n";
for(int i = 2; i >= 0; i--) cout << vb[i] << "\n";
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int t; cin >> t;
while(t--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... #... #..# .##. Yes ##.#. ..#.# .#... #.... #.... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... #.......................... #.......................... #.......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 11ms
memory: 3644kb
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: 11ms
memory: 3896kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... .######.................................. #........................................ .###############......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 11ms
memory: 3872kb
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: 3728kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### .##... #..... .#.... ..##.# ##..#. Yes .#.###### #.#...... #........ #........ #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .#####........................................... #..................
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 3ms
memory: 4556kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 6ms
memory: 4688kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.