QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#793220#9621. 连方happy_lazier#WA 10ms3744kbC++202.0kb2024-11-29 17:43:072024-11-29 17:43:15

Judging History

你现在查看的是最新测评结果

  • [2024-11-29 17:43:15]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:3744kb
  • [2024-11-29 17:43:07]
  • 提交

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;
		int t = 0;
		rep(i, 1, n) {
			if (s[1][i] == '.' && (s[1][i - 1] == '#' || s[1][i + 1] == '#')) {
				s[2][i] = '#';
				t = i;
				break;
			}
		}
		t %= 2;
		rep(i, 3, 5) {
			rep(j, 1, n) {
				if (i == 3 || i == 5) {
					if (j % 2 != t) {
						s[i][j] = '#';
					}
				}
				else {
					if (j % 2 == t) {
						s[i][j] = '#';
					}
				}
			}
		}
		rep(i, 1, n) {
			if (s[7][i] == '.' && (s[7][i - 1] == '#' || s[7][i + 1] == '#')) s[6][i] = '#';
		}
		rep(i, 1, n) {
			if (s[6][i] == '#' && s[6][i + 1] == '#') {
				if (s[5][i] == '#') s[5][i] = '.';
				if (s[5][i + 1] == '#') s[5][i + 1] = '.';
			}
		}

		rep(i, 1, n) {
			if (s[1][i] == '.' && (s[1][i - 1] == '#' || s[1][i + 1] == '#')) s[2][i] = '#';
		}
		rep(i, 1, n) {
			if (s[2][i] == '#' && s[2][i + 1] == '#') {
				if (s[3][i] == '#') s[3][i] = '.';
				if (s[3][i + 1] == '#') s[3][i + 1] = '.';
			}
		}

		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: 100
Accepted
time: 0ms
memory: 3612kb

input:

5
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
10
##########
##########

output:

Yes
#..#
.##.
#...
.#.#
#.#.
#..#
.##.
Yes
##.#.
..#.#
.#.#.
#.#.#
.#.#.
#.#..
.#.##
No
Yes
.######.######.####.#.#####
#......#......#....#.#.....
.#.#.#.#.#.#.#.#.#.#.#.#.#.
#.#.#.#.#.#.#.#.#.#.#.#.#.#
.#.#.#.#.#.#...#.#.#.#.#.#.
#....#.#....##.#.....#.....
.####...####..#.......#####
Yes
########...

result:

ok Correct.

Test #2:

score: -100
Wrong Answer
time: 10ms
memory: 3744kb

input:

10000
6
.#..##
..#...
5
#..#.
##...
6
.###.#
...###
17
.####..#######..#
###########.#####
6
..##.#
#.##.#
25
#.##.##############.####.
####################.##.#
9
##.#..##.
##..#####
6
.###.#
##.###
6
###..#
#.####
25
#####################.#.#
######.##################
6
.#.###
.##..#
6
..####
#......

output:

Yes
.#..##
#.##..
.#...#
#.#.#.
.#.#.#
.#.#..
..#...
Yes
#..#.
.##.#
#...#
.#.#.
#.#.#
..#..
##...
Yes
.###.#
#...#.
.#.#.#
#.#.#.
.#.#.#
..#...
...###
Yes
.####..#######..#
#....##.......##.
.#.#...#.#.#.#...
#.#.#.#.#.#.#.#.#
.#.#.#.#.#.#.#.#.
...........#.....
###########.#####
Yes
..##.#
.#..#.
...

result:

wrong answer Testcase 39: Connected condition failed.