結果
問題 | No.1434 Make Maze |
ユーザー |
|
提出日時 | 2021-03-20 00:38:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 2,559 bytes |
コンパイル時間 | 871 ms |
コンパイル使用メモリ | 96,384 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-24 21:47:29 |
合計ジャッジ時間 | 4,701 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
#include <iostream>#include <string>#include <algorithm>#include <vector>#include <iomanip>#include <cmath>#include <stdio.h>#include <queue>#include <deque>#include <cstdio>#include <set>#include <map>#include <bitset>#include <stack>#include <cctype>using namespace std;char ans[1010][1010];int main() {int h, w, x;cin >> h >> w >> x;bool bo = true;if (h % 4 == 3 && w % 4 == 3 && h != 3 && w != 3) {int now = h + w - 2;for (int i = 0; i < h; i++) {for (int j = 0; j < w; j++) {if (j == 0 || i % 2 == 0) {ans[i][j] = '.';}else {ans[i][j] = '#';}}}for (int i = 0; i < h - 3; i += 4) {for (int j = 1; j < w; j += 2) {if (now < x) {ans[i + 1][j - 1] = '#';ans[i][j] = '.';ans[i][j + 1] = '.';ans[i + 1][j + 1] = '.';ans[i + 2][j + 1] = '.';ans[i + 2][j] = '.';now += 4;}}}if (now != x) {for (int j = 1; j < w; j += 2) {if (now < x && j % 4 == 1) {ans[h - 3][j] = '#';ans[h - 2][j + 1] = '.';ans[h - 2][j + 3] = '.';ans[h - 1][j + 2] = '#';now += 4;}}}if (now != x) {cout << -1 << endl;return 0;}if (!bo) {for (int i = 0; i < w; i++) {for (int j = 0; j < h; j++) {cout << ans[j][i];}cout << endl;}}else {for (int i = 0; i < h; i++) {for (int j = 0; j < w; j++) {cout << ans[i][j];}cout << endl;}}return 0;}if ((h > w & !w == 3) || h == 3 || h % 4 == 3) {swap(h, w);bo = false;}if (h + w - 2 <= x) {if ((h + w - 2) % 4 == x % 4) {int now = h + w - 2;for (int i = 0; i < h; i++) {for (int j = 0; j < w; j++) {if (j == 0 || i % 2 == 0) {ans[i][j] = '.';}else {ans[i][j] = '#';}}}for (int i = 0; i < h - 3; i += 4) {for (int j = 1; j < w; j += 2) {if (now < x) {ans[i + 1][j - 1] = '#';ans[i][j] = '.';ans[i][j + 1] = '.';ans[i + 1][j + 1] = '.';ans[i + 2][j + 1] = '.';ans[i + 2][j] = '.';now += 4;}}}if (now != x) {cout << -1 << endl;return 0;}if (!bo) {for (int i = 0; i < w; i++) {for (int j = 0; j < h; j++) {cout << ans[j][i];}cout << endl;}}else {for (int i = 0; i < h; i++) {for (int j = 0; j < w; j++) {cout << ans[i][j];}cout << endl;}}}else {cout << -1 << endl;}}else {cout << -1 << endl;}}