結果

問題 No.1434 Make Maze
ユーザー SSRSSSRS
提出日時 2021-03-19 22:06:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,136 bytes
コンパイル時間 1,764 ms
コンパイル使用メモリ 170,324 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 17:01:35
合計ジャッジ時間 6,373 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  int X;
  cin >> X;
  if (X < H + W - 2 || X % 4 != (H + W - 2) % 4){
    cout << -1 << endl;
  } else {
    bool tr = false;
    if (W % 4 == 3){
      tr = true;
      swap(H, W);
    }
    vector<string> S(H, string(W, '.'));
    for (int i = 0; i < H; i++){
      for (int j = 1; j < W; j += 2){
        S[i][j] = '#';
      }
    }
    X -= H + W - 2;
    S[H - 1][1] = '.';
    for (int i = 3; i < W; i += 2){
      if (X >= H * 2){
        if (i < W - 1){
          S[0][i] = '.';
          S[H - 1][i + 2] = '.';
          X -= H * 2;
          i += 2;
        }
      } else {
        int a = H - 1 - X / 2;
        S[a][i] = '.';
        X = 0;
      }
    }
    if (X > 0){
      cout << -1 << endl;
    } else {
      if (tr){
        vector<string> S2(W, string(H, '.'));
        for (int i = 0; i < H; i++){
          for (int j = 0; j < W; j++){
            S2[j][i] = S[i][j];
          }
        }
        swap(S, S2);
        swap(H, W);
      }
      for (int i = 0; i < H; i++){
        cout << S[i] << endl;
      }
    }
  }
}
0