結果

問題 No.1434 Make Maze
ユーザー 夜
提出日時 2021-03-19 23:21:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,572 bytes
コンパイル時間 975 ms
コンパイル使用メモリ 95,348 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 19:08:21
合計ジャッジ時間 5,746 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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 && (x - now) % 8 == 0) {
			for (int j = 1; j < w; j += 4) {
				if (now < x) {
					ans[h - 3][j] = '#';
					ans[h - 2][j + 1] = '.';
					ans[h - 1][j + 2] = '#';
					ans[h - 2][j + 3] = '.';
					now += 8;
				}
			}
		}
		else 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;
	}
}
0