結果
| 問題 |
No.1434 Make Maze
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-19 23:13:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,542 bytes |
| コンパイル時間 | 1,059 ms |
| コンパイル使用メモリ | 95,176 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-19 01:19:56 |
| 合計ジャッジ時間 | 4,968 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 WA * 2 |
ソースコード
#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 += 4;
}
}
}
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 && w * (h + 1) / 2 + h / 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 (!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;
}
}