結果

問題 No.1434 Make Maze
ユーザー どららどらら
提出日時 2021-03-19 23:16:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,792 bytes
コンパイル時間 3,691 ms
コンパイル使用メモリ 227,664 KB
実行使用メモリ 4,456 KB
最終ジャッジ日時 2023-08-12 04:23:57
合計ジャッジ時間 9,502 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
//using mint = modint1000000007;
//using mint = modint998244353;

char f[1005][1005];

int main(){
  ll H, W, X;
  cin >> H >> W >> X;

  bool flip = false;
  if(H > W){
    flip = true;
    swap(H, W);
  }
  
  rep(i,H) rep(j,W) f[i][j] = '.';
  for(int i=1; i<W; i+=2){
    rep(j,H) f[j][i] = '#';
    if((i+1)%4!=0) f[H-1][i] = '.';
  }

  
  ll h = (H+1)/2;
  ll w = (W+1)/2;

  ll mn = (h-1)*2 + (w-1)*2;
  ll mx = 0;
  if((W-1)%4 == 0){
    mx = w*(h-1)*2 + (w-1)*2;

    if(X < mn || X > mx || (X-mn)%4!=0){
      cout << -1 << endl;
      return 0;
    }

    ll cnt = (mx-X)/4;
    vector<int> v;
    for(int i=3; i<W; i+=4) v.push_back(0);

    int p=0;
    while(cnt > 0){
      v[p]++;
      p++;
      if(p>=v.size()) p=0;
      cnt--;
    }
    for(int i=3; i<W; i+=4){
      f[2*v[(i-3)/4]][i] = '.';
    }
  }else{
    mx = (w-1)*(h-1)*2 + (w-1)*2;

    if(X < mn || X > mx || (X-mn)%4!=0){
      cout << -1 << endl;
      return 0;
    }

    ll cnt = (mx-X)/4;
    vector<int> v;
    for(int i=3; i<W; i+=4) v.push_back(0);

    int p=0;
    while(cnt > 0){
      v[p]++;
      p++;
      if(p>=v.size()) p=0;
      cnt--;
    }

    for(int i=3; i<W; i+=4){
      f[2*v[(i-3)/4]][i] = '.';
    }    
  }

  if(flip){
    rep(i,W){
      rep(j,H){
        cout << f[j][i];
      }
      cout << endl;
    }
  }else{
    rep(i,H){
      rep(j,W){
        cout << f[i][j];
      }
      cout << endl;
    }
  }
  
  return 0;
}
0