結果
| 問題 |
No.1434 Make Maze
|
| コンテスト | |
| ユーザー |
sten_san
|
| 提出日時 | 2021-03-19 23:41:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,620 bytes |
| コンパイル時間 | 2,328 ms |
| コンパイル使用メモリ | 199,796 KB |
| 最終ジャッジ日時 | 2025-01-19 19:46:15 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 8 WA * 3 RE * 19 |
ソースコード
#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;
}
}
sten_san