結果

問題 No.1434 Make Maze
ユーザー yuusanlondon
提出日時 2021-03-19 22:29:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,029 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 83,840 KB
最終ジャッジ日時 2024-11-18 23:17:40
合計ジャッジ時間 7,352 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 9 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m,x=map(int,input().split())
r=((m-1)//2)*((n-1)//2)*2
if x>m*n-1-r or x<m+n-2 or (x-(m+n-2))%4!=0:
  print(-1)
  exit()
ans=[]
for i in range(n):
  ans.append([])
  for j in range(m):
    if i%2 and j%2:
      ans[-1].append('#')
    else:
      ans[-1].append('.')
stock=(m*n-1-r-x)//4
if m<n:
  count=0
  for i in range(1,n,2):
    if count%2:
      for j in range(1,m,2):
        if stock:
          ans[i][j-1]='#'
          stock-=1
        else:
          ans[i][j+1]='#'
    else:
      for j in range(m-2,0,-2):
        if stock:
          ans[i][j+1]='#'
          stock-=1
        else:
          ans[i][j-1]='#'
    count+=1
else:
  count=0
  for i in range(1,m,2):
    if count%2:
      for j in range(1,n,2):
        if stock:
          ans[j-1][i]='#'
          stock-=1
        else:
          ans[j+1][i]='#'
    else:
      for j in range(n-2,0,-2):
        if stock:
          ans[j+1][i]='#'
          stock-=1
        else:
          ans[j-1][i]='#'
    count+=1
for i in range(n):
  print(''.join(ans[i]))
0