結果
問題 | No.1434 Make Maze |
ユーザー | trineutron |
提出日時 | 2021-03-19 23:26:49 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 3,084 bytes |
コンパイル時間 | 2,109 ms |
コンパイル使用メモリ | 204,672 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-24 21:41:16 |
合計ジャッジ時間 | 6,101 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 6 ms
6,816 KB |
testcase_03 | AC | 6 ms
6,820 KB |
testcase_04 | AC | 2 ms
6,816 KB |
testcase_05 | AC | 2 ms
6,816 KB |
testcase_06 | AC | 2 ms
6,820 KB |
testcase_07 | AC | 2 ms
6,816 KB |
testcase_08 | AC | 2 ms
6,816 KB |
testcase_09 | AC | 2 ms
6,820 KB |
testcase_10 | AC | 2 ms
6,816 KB |
testcase_11 | AC | 2 ms
6,820 KB |
testcase_12 | AC | 2 ms
6,820 KB |
testcase_13 | AC | 2 ms
6,820 KB |
testcase_14 | AC | 2 ms
6,820 KB |
testcase_15 | AC | 4 ms
6,816 KB |
testcase_16 | AC | 2 ms
6,820 KB |
testcase_17 | AC | 2 ms
6,816 KB |
testcase_18 | AC | 3 ms
6,816 KB |
testcase_19 | AC | 4 ms
6,820 KB |
testcase_20 | AC | 1 ms
6,816 KB |
testcase_21 | AC | 2 ms
6,816 KB |
testcase_22 | AC | 2 ms
6,824 KB |
testcase_23 | AC | 2 ms
6,816 KB |
testcase_24 | AC | 3 ms
6,820 KB |
testcase_25 | AC | 5 ms
6,820 KB |
testcase_26 | AC | 2 ms
6,820 KB |
testcase_27 | AC | 3 ms
6,816 KB |
testcase_28 | AC | 2 ms
6,816 KB |
testcase_29 | AC | 2 ms
6,816 KB |
testcase_30 | AC | 3 ms
6,816 KB |
testcase_31 | AC | 3 ms
6,816 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int h, w, x; cin >> h >> w >> x; int hhalf = h / 2, whalf = w / 2, rest = x / 2 - hhalf - whalf, longest = (hhalf + 1) * (whalf + 1) - 1; if (x % 2 or x / 2 % 2 != (hhalf + whalf) % 2 or rest < 0 or longest < x / 2) { cout << -1 << endl; return 0; } vector<string> ans(h); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { ans.at(i).push_back('.'); if (i % 2 and j % 2) { ans.at(i).at(j) = '#'; } } } if (hhalf % 2 == 0) { int prevhole = 0; for (int i = 1; i < h; i += 2) { int hole = 2 * whalf; if (rest >= prevhole and prevhole) { hole = 0; rest -= prevhole; } else if (rest and prevhole) { hole = prevhole - rest; rest = 0; } prevhole = hole; for (int j = 0; j < w; j += 2) { if (j != hole) { ans.at(i).at(j) = '#'; } } } } else if (whalf % 2 == 0) { int prevhole = 0; for (int i = 1; i < w; i += 2) { int hole = 2 * hhalf; if (rest >= prevhole and prevhole) { hole = 0; rest -= prevhole; } else if (rest and prevhole) { hole = prevhole - rest; rest = 0; } prevhole = hole; for (int j = 0; j < h; j += 2) { if (j != hole) { ans.at(j).at(i) = '#'; } } } } else { int prevhole = 0; for (int i = 1; i < h; i += 2) { int hole = 2 * whalf; if (i >= h - 2 and rest) { break; } if (rest >= prevhole and prevhole) { hole = 0; rest -= prevhole; } else if (rest and prevhole) { hole = prevhole - rest; rest = 0; } prevhole = hole; for (int j = 0; j < w; j += 2) { if (j != hole) { ans.at(i).at(j) = '#'; } } } if (rest) { prevhole = h - 3; for (int i = 1; i < w; i += 2) { int hole = h - 3; if (rest and prevhole == h - 3) { hole = h - 1; rest -= 2; } prevhole = hole; ans.at(2 * h - 4 - hole).at(i) = '#'; } } } for (auto &&s : ans) { cout << s << '\n'; } return 0; }