QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#738115 | #9621. 连方 | ucup-team4975# | AC ✓ | 24ms | 3924kb | C++14 | 2.4kb | 2024-11-12 17:46:58 | 2024-11-12 17:46:58 |
Judging History
answer
#include <bits/stdc++.h>
#define el '\n'
using namespace std;
using ll = long long;
void solve() {
int n;
cin >> n;
string s[8];
int flag1 = 1, flag2 = 1;
cin >> s[1] >> s[7];
s[1] = " " + s[1];
s[7] = " " + s[7];
for (int i =2 ; i <= 6; i++) {
s[i] = s[1];
}
for (int i = 1; i<= n; i++) {
if (s[1][i] == '.')
flag1 = 0;
if (s[7][i] == '.')
flag2 = 0;
for (int j = 2; j <= 6; j++) {
s[j][i] = '.';
}
}
if (flag1 == 1 && flag2 == 1) {
cout << "Yes" << el;
for (int i= 1; i <= 7; i++) {
for (int j = 1; j <= n; j++) {
cout << '#';
}
cout << el;
}
return;
}
if (flag1 != flag2) {
cout << "No" << el;
return;
}
for (int i = 1; i <= n; i++) {
if (s[1][i] == '#')
s[2][i] = '.';
else
s[2][i] = '#';
if (s[7][i] == '#')
s[6][i] = '.';
else
s[6][i] = '#';
}
int x, y;
for (int i = 1; i < n; i++) {
if (s[2][i] == '.' && s[2][i + 1] == '#') {
x = i;
break;
}
if (s[2][i] == '#' && s[2][i + 1] == '.') {
x = i + 1;
break;
}
}
for (int i = 1; i < n; i++) {
if (s[6][i] == '.' && s[6][i + 1] == '#') {
y = i;
break;
}
if (s[6][i] == '#' && s[6][i + 1] == '.') {
y = i + 1;
break;
}
}
s[3][x] = '#', s[5][y] = '#';
if (x > y)
swap(x, y);
if (x == y) {
s[4][x] = '#';
}
else if (y == x + 1) {
s[4][x] = '#';
}
else {
for (int i = x + 1; i < y; i++) {
s[4][i] = '#';
}
}
cout << "Yes" << el;
for (int i = 1; i <= 7; i++) {
for (int j = 1; j <= n; j++) {
cout << s[i][j];
}
cout << endl;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
/*
1
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3552kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 23ms
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: 23ms
memory: 3616kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 24ms
memory: 3616kb
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: 23ms
memory: 3668kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... .#.... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... #........ #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 7ms
memory: 3924kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 12ms
memory: 3924kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.