QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#737649 | #9621. 连方 | huo_hua_ya# | AC ✓ | 14ms | 4196kb | C++23 | 3.7kb | 2024-11-12 16:30:21 | 2024-11-12 16:30:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 7;
const int mod = 998244353;
void solve()
{
int n;
cin >> n;
string s1, s2;
cin >> s1 >> s2;
set<char>st1, st2;
for (auto x : s1) {
st1.insert(x);
}
for (auto x : s2) {
st2.insert(x);
}
if (st1.size() == 1 && st2.size() == 2) {
if (s1.back() == '#') {
cout << "No" << '\n';
return;
}
cout << "Yes" << '\n';
for (int i = 0; i < 5; i++) {
for (int j = 0; j < n; j++) {
cout << '.';
}
cout << '\n';
}
string str = "";
for (auto x : s2) {
if (x == '.') {
str += "#";
} else {
str += ".";
}
}
cout << str << '\n';
cout << s2 << '\n';
return;
}
if (st1.size() == 2 && st2.size() == 1) {
if (s2.back() == '#') {
cout << "No" << '\n';
return;
}
cout << "Yes" << '\n';
string str = "";
for (auto x : s1) {
if (x == '.') {
str += "#";
} else {
str += ".";
}
}
cout << s1 << '\n';
cout << str << '\n';
for (int i = 2; i < 7; i++) {
for (int j = 0; j < n; j++) {
cout << '.';
}
cout << '\n';
}
return;
}
if(st1.size()==1&&st2.size()==1){
cout << "Yes" << '\n';
for(int i=0;i<6;i++){
cout << s1 << '\n';
}
cout << s2 << '\n';
return;
}
cout << "Yes" << '\n';
string str1 = "",str2 = "";
for(auto x:s1){
if(x == '#'){
str1 += '.';
}else {
str1 += '#';
}
}
for(auto x:s2){
if(x == '#'){
str2 += '.';
}else {
str2 += '#';
}
}
int f1 = -1,f2 = -1;
for(int i=0;i<n;i++){
if(s1[i] == '#'&&((i+1<n&&s1[i + 1]=='.')||(i-1>=0&&s1[i - 1]=='.'))){
f1 = i;
break;
}
}
for(int i=0;i<n;i++){
if(s2[i] == '#'&&((i+1<n&&s2[i + 1]=='.')||(i-1>=0&&s2[i - 1]=='.'))){
f2 = i;
break;
}
}
cout << s1 << '\n';
cout << str1 << '\n';
for(int i=0;i<n;i++){
if(i == f1){
cout << '#' ;
}else cout << '.' ;
}
cout << '\n';
if(f1 == f2){
for(int i=0;i<n;i++){
if(i==f1){
cout << '#';
}else {
cout << '.';
}
}
}else if(abs(f1 - f2)!=1){
int x = f1,y = f2;
if(x > y)swap(x,y);
for(int i=0;i<=x;i++){
cout << '.';
}
for(int i=x+1;i<y;i++){
cout << '#';
}
for(int i=y;i<n;i++){
cout << '.';
}
}else {
int x = f1,y = f2;
if(x > y)swap(x,y);
for(int i=0;i<=x;i++){
cout << '.';
}
for(int i=x+1;i<=y;i++){
cout << '#';
}
for(int i=y+1;i<n;i++){
cout << '.';
}
}
cout << '\n';
for(int i=0;i<n;i++){
if(i == f2){
cout << '#' ;
}else cout << '.' ;
}
cout << '\n';
cout << str2 << '\n';
cout << s2 << '\n';
}
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _ = 1;
cin >> _;
while (_--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3864kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... .#.. .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 14ms
memory: 3676kb
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: 10ms
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: 14ms
memory: 3676kb
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: 14ms
memory: 3616kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ..#... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... .#....... #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 11ms
memory: 4196kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 12ms
memory: 3900kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.