結果

問題 No.1434 Make Maze
ユーザー sten_sansten_san
提出日時 2021-03-19 23:41:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,620 bytes
コンパイル時間 2,187 ms
コンパイル使用メモリ 207,616 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 19:39:49
合計ジャッジ時間 7,210 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
5,376 KB
testcase_10 WA -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

struct iofast_t {
    iofast_t() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr); cout.tie(nullptr);
    }
} iofast;

struct uns_t {} uns;
template <typename Element, typename Head, typename ...Args>
auto vec(Element init, Head arg, Args ...args) {
    if constexpr (sizeof...(Args) == 0) return std::vector(arg, init);
    else return std::vector(arg, vec(init, args...));
}
template <typename Element, typename Head, typename ...Args>
auto vec(uns_t, Head arg, Args ...args) {
    return vec(Element(), arg, args...);
}

template <typename T, typename Compare = less<T>>
T &chmin(T &l, T r, Compare &&f = less<T>()) { return l = min(l, r, f); }
template <typename T, typename Compare = less<T>>
T &chmax(T &l, T r, Compare &&f = less<T>()) { return l = max(l, r, f); }

optional<vector<string>> solver(int h, int w, int q) {
    int d = h + w - 2;
    if (d % 4 != q % 4 || q < d || (h / 2) * (w / 4) < (q - d) / 4) {
        return nullopt;
    }

    // 凸 の数
    // w / 4;
    // 1凸 にいくつのポイントがあるか
    // h / 2;

    int use = (q - d) / 4;
    auto ans = vec(string(w, '#'), h);

    int x = 0, y = 0;
    for (int i = 0; i < w / 2; ++i) {
        for (int j = y; j < h; ++j) {
            ans[j][x] = '.';
        }
        y = 0;

        if (w <= ++x) {
            break;
        }
        ans[h - 1][x++] = '.';

        if (x == w - 1) {
            ans[h - 1][x] = '.';
            break;
        }

        for (int j = 0; j < h && use != 0; j += 2, --use) {
            ans[h - j - 1][x] = '.';
            ans[h - j - 2][x] = '.';
            ans[h - j - 3][x] = '.';

            if (use == 1) {
                ans[h - j - 3][x + 1] = '.';
                y = h - j - 3;
            }
        }
        x += 2;
    }

    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if (i % 2 && j % 2) {
                ans[i - 1][j - 1] = '.';
            }
        }
    }

    return ans;
}

int main() {
    int h, w, x; cin >> h >> w >> x;

    auto op1 = solver(h, w, x);
    auto op2 = solver(w, h, x);

    if (!op1.has_value() && !op2.has_value())  {
        cout << -1 << endl;
        return 0;
    }

    if (op1.has_value()) {
        for (auto e1 : op1.value()) {
            for (auto e2 : e1) {
                cout << e2;
            }
            cout << endl;
        }
        return 0;
    }

    auto ans = op2.value();
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cout << ans[j][i];
        }
        cout << endl;
    }
}

0