結果

問題 No.1434 Make Maze
ユーザー norikamenorikame
提出日時 2021-03-19 23:43:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,834 bytes
コンパイル時間 2,124 ms
コンパイル使用メモリ 205,084 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 19:42:18
合計ジャッジ時間 6,528 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
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 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 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;

using ll = long long;
using ull = unsigned long long;
#define v(t) vector<t>
#define p(t) pair<t, t>
#define p2(t, s) pair<t, s>
#define vp(t) v(p(t))

#define rep(i, n) for (int i=0,i##_len=((int)(n)); i<i##_len; ++i)
#define rep2(i, a, n) for (int i=((int)(a)),i##_len=((int)(n)); i<=i##_len; ++i)
#define repr(i, n) for (int i=((int)(n)-1); i>=0; --i)
#define rep2r(i, a, n) for (int i=((int)(n)),i##_len=((int)(a)); i>=i##_len; --i)

#define repi(itr, c) for (__typeof((c).begin()) itr=(c).begin(); itr!=(c).end(); ++itr)
#define repir(itr, c) for (__typeof((c).rbegin()) itr=(c).rbegin(); itr!=(c).rend(); ++itr)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define eb emplace_back

#define INF (1e9)
#define LINF (1e18)
#define PI (acos(-1))
#define EPS (1e-7)
#define DEPS (1e-10)

int main(){
    int h, w, x;
    cin >> h >> w >> x;
    if (x%2 != 0) {
        cout << -1 << endl;
        return 0;
    }
    if (x < h+w-2) {
        cout << -1 << endl;
        return 0;
    }
    if ((h+1)/2%2!=0 || (w+1)/2%2!=0) {
        int mxval = ((h+1)/2*(w+1)/2-1);
        if (x > mxval*2) {
            cout << -1 << endl;
            return 0;
        }
        bool r = false;
        if ((h+1)/2%2!=0 && (w+1)/2%2!=0) r = (h>=w);
        else r = ((w+1)/2%2 == 0);
        int h2 = (h+1)/2, w2 = (w+1)/2, x2 = x/2 + 1;
        int add = x2 - (h2+w2-1);
        if (add%2 != 0) {
            cout << -1 << endl;
            return 0;
        }
        if (!r) swap(h, w);
        v(string) ans(h, string(w, '.'));
        rep(i, h) rep(j, w) if (i%2!=0&&j%2!=0) ans[i][j] = '#';
        int len1 = add / ((h2-1)*2), len2 = add % ((h2-1)*2) / 2;
        for (int i=0; i<h-2; i+=2) ans[i][1] = '#';
        for (int i=0; i<len1; ++i) {
            int i2 = 2 + 4*i;
            for (int j=h-1; j>=2; j-=2) ans[j][i2+1] = '#';
            for (int j=0; j<h-2; j+=2) ans[j][i2+3] = '#';
        }
        int i3 = 2 + 4*len1;
        for (int i=h-1; i>h-2*len2-1; i-=2) ans[i][i3+1] = '#';
        for (int i=h-1-2*len2; i<h-2; i+=2) ans[i][i3+3] = '#';
        if (len2 > 0) {
            ans[h-1-2*len2-2][i3] = ans[h-1-2*len2-2][i3+2] = '#';
        }
        for (int i=h-1-2*len2-2; i>=0; i-=2) ans[i][i3+1] = ans[i][i3+3] = '#';
        for (int i=i3+4; i+1<w; i+=2) for (int j=0; j<h-2; ++j) ans[i][j] = '#';
        if (r) rep(i, h) cout << ans[i] << endl;
        else {
            rep(i, w) {
                string tmp;
                rep(j, h) tmp += ans[j][i];
                cout << tmp << endl;
            }
        }
    }
    else cout << -1 << endl;
    return 0;
}
0