QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#770181 | #9621. 连方 | proven# | WA | 23ms | 3932kb | C++20 | 2.2kb | 2024-11-21 21:00:45 | 2024-11-21 21:00:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
const int mod = 998244353;
void solve() {
int n; cin >> n;
string a, b;
cin >> a >> b;
vector<vector<int> > ans(8, vector<int> (n + 1));
a = ' ' + a;
b = ' ' + b;
for(int i = 1;i <= n;i++) {
if(a[i] == '#') ans[1][i] = 1;
if(b[i] == '#') ans[7][i] = 1;
}
auto out = [&] () {
for(int i = 1;i <= 7;i++) {
for(int j = 1;j <= n;j++) {
if(ans[i][j]) cout << '#';
else cout << ".";
}
cout << endl;
}
};
int x = 0, y = 0;
for(int i = 1;i <= n;i++) {
x += (a[i] == '#');
y += (b[i] == '#');
}
if(x == 0) {
cout << "Yes" << endl;
for(int i = 1;i <= n;i++) {
ans[6][i] = ans[7][i] ^ 1;
}
out();
return;
}
if(x == n) {
if(y == n || y == 0) {
cout << "Yes" << endl;
for(int j = 2;j <= 6;j++) {
for(int i = 1;i <= n;i++) ans[j][i] = 1;
}
out();
}
else {
cout << "No" << endl;
}
return;
}
for(int i = 1;i <= n;i++) {
ans[2][i] = ans[1][i] ^ 1;
ans[6][i] = ans[7][i] ^ 1;
}
int mn = 1e9, mx = 0;
for(int i = 1;i < n;i++) {
if(ans[2][i] && !ans[2][i + 1]) mn = min(mn, i + 1);
if(ans[6][i] && !ans[6][i + 1]) mx = max(mx, i + 1);
if(ans[2][i+1] && !ans[2][i]) mn = min(mn, i);
if(ans[6][i+1] && !ans[6][i]) mx = max(mx, i);
}
ans[3][mn] = 1;
ans[5][mx] = 1;
if(mn > mx) swap(mn, mx);
if(mn == mx) {
ans[4][mn] = 1;
}
else {
if(abs(mn - mx) == 1) ans[4][mn] = 1;
else {
for(int i = mn + 1;i < mx;i++) ans[4][i] = 1;
}
}
cout << "Yes" << endl;
out();
}
/*
4
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
*/
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... .#.. ..#. #..# .##. Yes ##.#. ..#.# .#... ..#.. ...#. #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... ..####################..... ......................#.... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: -100
Wrong Answer
time: 23ms
memory: 3932kb
input:
10000 6 .#..## ..#... 5 #..#. ##... 6 .###.# ...### 17 .####..#######..# ###########.##### 6 ..##.# #.##.# 25 #.##.##############.####. ####################.##.# 9 ##.#..##. ##..##### 6 .###.# ##.### 6 ###..# #.#### 25 #####################.#.# ######.################## 6 .#.### .##..# 6 ..#### #......
output:
Yes .#..## #.##.. .#.... .#.... ..#... ##.### ..#... Yes #..#. .##.# #.... #.... .#... ..### ##... Yes .###.# #...#. .#.... ..#... ...#.. ###... ...### Yes .####..#######..# #....##.......##. .#............... ..##########..... ............#.... ...........#..... ###########.##### Yes ..##.# ##..#. ...
result:
wrong answer Testcase 48: output is YES, but jury's answer is NO.