QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#793247 | #9621. 连方 | happy_lazier# | WA | 0ms | 3560kb | C++20 | 1.7kb | 2024-11-29 17:57:25 | 2024-11-29 17:57:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define rep(i,l,r) for(ll i=l;i<=r;++i)
#define rep_(i,r,l) for(ll i=r;i>=l;--i)
const ll N = 2e5 + 7;
const ll P = 998244353;
ll qpow(ll x, ll b) {
ll res = 1;
while (b) {
if (b & 1)res = (res * x) % P;
x = x * x % P;
b >>= 1ll;
}
return res;
}
ll inv(ll x) { return qpow(x, P - 2); }
void solve() {
ll n; cin >> n;
string s[8];
cin >> s[1] >> s[7];
s[1] = '.' + s[1] + '.', s[7] = '.' + s[7] + '.';
rep(i, 2, 6) {
s[i] = "";
rep(j, 1, n + 2) s[i] += '.';
}
int f1 = 0, f2 = 0;
rep(i, 1, n) {
if (s[1][i] != '#')f1 = 1;
if (s[7][i] != '#')f2 = 1;
}
if (f1 == 0 && f2 == 0) {
cout << "Yes" << endl;
rep(i, 1, 7) {
rep(j, 1, n) {
cout << "#";
}
cout << endl;
}
}
else if (f1 == 1 && f2 == 1) {
cout << "Yes" << endl;
rep(i, 1, n) {
if (s[1][i] == '.' && (s[1][i - 1] == '#' || s[1][i + 1] == '#')) s[2][i] = '#';
if (s[7][i] == '.' && (s[7][i - 1] == '#' || s[7][i + 1] == '#')) s[6][i] = '#';
}
ll pos1 = 0, pos2 = 0;
rep(i, 1, n) {
if (s[2][i] == '.' && (s[2][i - 1] == '#' || s[2][i + 1] == '#')) {
s[3][i] = '#';
pos1 = i;
break;
}
}
rep(i, 1, n) {
if (s[6][i] == '.' && (s[6][i - 1] == '#' || s[6][i + 1] == '#')) {
s[5][i] = '#';
pos2 = i;
break;
}
}
if (pos1 == pos2) s[4][pos1] = '#';
else {
rep(i, min(pos1, pos2) + 1, max(pos1, pos2) - 1) s[4][i] = '#';
}
rep(i, 1, 7) {
rep(j, 1, n) cout << s[i][j];
cout << endl;
}
}
else {
cout << "No" << endl;
return;
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int T(1);
cin >> T;
while (T--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3560kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... .... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....#.#....##.#.....#..... .####...####..#.......##### Yes ########...
result:
wrong answer Testcase 1: Connected condition failed.