結果

問題 No.179 塗り分け
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-24 15:16:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 3,000 ms
コード長 962 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 78,636 KB
最終ジャッジ日時 2023-09-07 13:23:11
合計ジャッジ時間 6,602 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,616 KB
testcase_01 AC 73 ms
71,324 KB
testcase_02 AC 71 ms
71,356 KB
testcase_03 AC 69 ms
71,256 KB
testcase_04 AC 69 ms
71,148 KB
testcase_05 AC 71 ms
71,364 KB
testcase_06 AC 86 ms
76,148 KB
testcase_07 AC 72 ms
75,392 KB
testcase_08 AC 134 ms
78,040 KB
testcase_09 AC 139 ms
78,044 KB
testcase_10 AC 107 ms
77,888 KB
testcase_11 AC 105 ms
77,632 KB
testcase_12 AC 157 ms
78,360 KB
testcase_13 AC 73 ms
71,500 KB
testcase_14 AC 75 ms
75,492 KB
testcase_15 AC 70 ms
71,444 KB
testcase_16 AC 70 ms
71,084 KB
testcase_17 AC 74 ms
71,392 KB
testcase_18 AC 128 ms
77,940 KB
testcase_19 AC 128 ms
77,924 KB
testcase_20 AC 77 ms
75,592 KB
testcase_21 AC 75 ms
75,280 KB
testcase_22 AC 158 ms
78,532 KB
testcase_23 AC 109 ms
77,548 KB
testcase_24 AC 140 ms
78,480 KB
testcase_25 AC 110 ms
77,484 KB
testcase_26 AC 122 ms
77,724 KB
testcase_27 AC 149 ms
78,328 KB
testcase_28 AC 129 ms
78,132 KB
testcase_29 AC 156 ms
78,636 KB
testcase_30 AC 141 ms
78,308 KB
testcase_31 AC 164 ms
78,588 KB
testcase_32 AC 128 ms
78,148 KB
testcase_33 AC 141 ms
78,504 KB
testcase_34 AC 123 ms
78,080 KB
testcase_35 AC 146 ms
78,392 KB
testcase_36 AC 71 ms
71,204 KB
testcase_37 AC 69 ms
71,352 KB
testcase_38 AC 69 ms
71,428 KB
testcase_39 AC 73 ms
71,212 KB
testcase_40 AC 69 ms
71,444 KB
testcase_41 AC 68 ms
71,444 KB
testcase_42 AC 69 ms
71,556 KB
testcase_43 AC 81 ms
76,464 KB
testcase_44 AC 95 ms
77,860 KB
testcase_45 AC 75 ms
75,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main1(h,w,s):
  ary=[]
  for i in range(h):
    for j in range(w):
      if s[i][j]=="#":
        ary.append((i,j))
  if len(ary)%2==1:return False
  if len(ary)==0:return False
  # 平行移動のパターンはH*W-1
  # すべて試す
  ary_st=set(ary)
  for i in range(-h,h):
    for j in range(-w,w):
      if i==0 and j==0:continue
      mat=[[0]*w for _ in range(h)]
      flg=True
      for x,y in ary:
        if mat[x][y]==1:continue
        if 0<=x+i<h and 0<=y+j<w and (x+i,y+j) in ary_st and mat[x+i][y+j]==0:
          mat[x+i][y+j]=1
          mat[x][y]=1
        elif 0<=x-i<h and 0<=y+j<w and (x-i,y-j) in ary_st and mat[x-i][y-j]==0:
          mat[x-i][y-j]=1
          mat[x][y]=1
        else:
          flg=False
          break
      if flg:
        return True
  return False
if __name__=='__main__':
  h,w=map(int,input().split())
  s=[input() for _ in range(h)]
  ret1=main1(h,w,s)
  if ret1:
    print("YES")
  else:
    print("NO")
0