結果
| 問題 | No.1434 Make Maze | 
| コンテスト | |
| ユーザー |  merom686 | 
| 提出日時 | 2021-03-20 00:08:53 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 2,000 ms | 
| コード長 | 1,922 bytes | 
| コンパイル時間 | 895 ms | 
| コンパイル使用メモリ | 91,704 KB | 
| 最終ジャッジ日時 | 2025-01-19 19:52:57 | 
| ジャッジサーバーID (参考情報) | judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 30 | 
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
char c[999][1000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, x;
    cin >> h >> w >> x;
    h = (h + 1) / 2;
    w = (w + 1) / 2;
    if (x % 2 != 0) {
        cout << -1 << endl;
        exit(0);
    }
    x /= 2;
    int x0 = (h - 1) + (w - 1), x1 = h * w - 1;
    if ((x1 - x0) % 2 != 0) x1--;
    if (!(x0 <= x && x <= x1 && (x - x0) % 2 == 0)) {
        cout << -1 << endl;
        exit(0);
    }
    x -= x0;
    x /= 2;
    for (int i = 0; i < h * 2 - 1; i++) {
        for (int j = 0; j < w * 2 - 1; j++) {
            c[i][j] = '#';
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            c[i * 2][j * 2] = '.';
        }
    }
    for (int j = 0; j < w - 1; j++) {
        c[0][j * 2 + 1] = '.';
    }
    for (int i = 0; i < h - 1; i++) {
        c[i * 2 + 1][(w - 1) * 2] = '.';
    }
    for (int i = h - 2; i > 0; i -= 2) {
        int f = x == 0;
        for (int j = w - 2; j >= 0; j--) {
            c[i * 2 + 0][j * 2 + 1] = '.';
            c[i * 2 + 2][j * 2 + 1] = '.';
            if (x > 0) x--;
            if (f == 0 && (j == 0 || x == 0)) {
                c[i * 2 + 1][(w - 1) * 2] = '#';
                c[i * 2 + 1][j * 2] = '.';
                f = 1;
            }
        }
    }
    if (h % 2 == 0) {
        for (int j = w - 3; j >= 0; j -= 2) {
            c[1][j * 2 + 0] = '.';
            c[1][j * 2 + 2] = '.';
            if (x > 0) {
                c[0][j * 2 + 1] = '#';
                c[2][j * 2 + 1] = '.';
                x--;
            }
        }
        if (w % 2 == 0) {
            c[1][0] = '.';
        }
    }
    for (int i = 0; i < h * 2 - 1; i++) {
        cout << c[i] << '\n';
    }
    return 0;
}
            
            
            
        