QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#811500#9621. 连方TosakaUCW#RE 0ms0kbC++203.1kb2024-12-12 20:06:162024-12-12 20:06:25

Judging History

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

  • [2024-12-12 20:06:25]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-12-12 20:06:16]
  • 提交

answer

#include <bits/stdc++.h>
using i64 = long long;
#define int i64
#define pb push_back
#define ep emplace
#define eb emplace_back
using std::cerr;
// using namespace std::views;
// using namespace std::ranges;
using std::max, std::min, std::swap, std::array;
using std::cin, std::cout, std::string, std::vector;
using std::ostream;
template <class T1, class T2> ostream &operator<<(ostream &os, const std::pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << '\n'; }
using pii = std::pair<int, int>;
#define fi first
#define se second

double eps = 1e-7;
const int inf = 1e18;

void solve() {
    int n; cin >> n;
    
    string s, t;
    cin >> s >> t;

    int cnt1 = 0;
    int cnt2 = 0;
    for (auto ch : s) cnt1 += ch == '#';
    for (auto ch : t) cnt2 += ch == '#';

    if (cnt1 < cnt2) swap(cnt1, cnt2);

    if (cnt1 == cnt2 and cnt1 == n) {

    } else if (cnt1 == n and cnt1 != cnt2) {
        cout << "No\n";
        return;
    }

    vector<string> a(7);
    // a[0] = s, a[6] = t;
    string sr = s;
    string tr = t;
    for (auto &ch : sr) ch = (ch == '.' ? '#' : '.');
    for (auto &ch : tr) ch = (ch == '.' ? '#' : '.');

    a[0] = s;
    a[1] = sr;
    a[5] = tr;
    a[6] = t;

    a[2].assign(n, '.');
    a[3].assign(n, '.');
    a[4].assign(n, '.');

    int p1 = -inf, p2 = -inf;

    for (int i = 0; i < n and p1 == -inf; i++) {
        // cout << i + 1 << '\n';
        if (a[1][i] == '#') {
            if (i + 1 < n and a[1][i + 1] != '#') {
                a[2][i + 1] = '#';
                p1 = i + 1;
                break;
            }
            if (i - 1 >= 0 and a[1][i - 1] != '#') {
                a[2][i - 1] = '#';
                p1 = i - 1;
                break;
            }
        }
    }
    // cout << 1 << '\n';
    for (int i = 0; i < n and p2 == -inf; i++) {
        if (a[5][i] == '#') {

            if (i + 1 < n and a[5][i + 1] != '#') {
                // cout << '9';
                a[4][i + 1] = '#';
                p2 = i + 1;
                break;
            }
            if (i - 1 >= 0 and a[5][i - 1] != '#') {
                a[4][i - 1] = '#';
                p2 = i - 1;
                // assert(0);
                break;
            }
        }
    }

    // cerr << a[4] << '\n';

    if (abs(p1 - p2) <= 1) {
        a[3][p1] = '#';
    } else {
        if (p1 > p2) swap(p1, p2);
        for (int i = p1 + 1; i < p2; i++) {
            a[3][i] = '#';
        }
    }



    for (int i = 0; i < 7; i++) {
        cout << a[i] << '\n';
    }
    // cerr << "----\n";
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T; cin >> T;
    for (; T--; solve());
    // solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

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

output:


result: