結果

問題 No.179 塗り分け
ユーザー siganaisiganai
提出日時 2022-05-26 16:35:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 100 ms / 3,000 ms
コード長 1,328 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 77,440 KB
最終ジャッジ日時 2023-10-20 19:29:44
合計ジャッジ時間 4,443 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
63,544 KB
testcase_01 AC 51 ms
63,544 KB
testcase_02 AC 52 ms
63,544 KB
testcase_03 AC 53 ms
63,544 KB
testcase_04 AC 51 ms
63,544 KB
testcase_05 AC 50 ms
63,544 KB
testcase_06 AC 51 ms
63,544 KB
testcase_07 AC 55 ms
66,116 KB
testcase_08 AC 56 ms
66,256 KB
testcase_09 AC 54 ms
66,256 KB
testcase_10 AC 58 ms
68,528 KB
testcase_11 AC 59 ms
68,528 KB
testcase_12 AC 100 ms
77,440 KB
testcase_13 AC 51 ms
63,544 KB
testcase_14 AC 51 ms
63,544 KB
testcase_15 AC 51 ms
63,544 KB
testcase_16 AC 51 ms
63,544 KB
testcase_17 AC 54 ms
63,544 KB
testcase_18 AC 61 ms
68,532 KB
testcase_19 AC 61 ms
70,576 KB
testcase_20 AC 55 ms
66,180 KB
testcase_21 AC 55 ms
66,116 KB
testcase_22 AC 78 ms
76,904 KB
testcase_23 AC 60 ms
68,396 KB
testcase_24 AC 67 ms
72,748 KB
testcase_25 AC 58 ms
66,256 KB
testcase_26 AC 61 ms
68,528 KB
testcase_27 AC 77 ms
76,928 KB
testcase_28 AC 67 ms
70,588 KB
testcase_29 AC 86 ms
77,120 KB
testcase_30 AC 80 ms
77,064 KB
testcase_31 AC 81 ms
77,000 KB
testcase_32 AC 75 ms
76,740 KB
testcase_33 AC 84 ms
77,128 KB
testcase_34 AC 76 ms
76,732 KB
testcase_35 AC 90 ms
77,100 KB
testcase_36 AC 51 ms
63,544 KB
testcase_37 AC 51 ms
63,544 KB
testcase_38 AC 52 ms
63,544 KB
testcase_39 AC 51 ms
63,544 KB
testcase_40 AC 52 ms
63,544 KB
testcase_41 AC 51 ms
63,544 KB
testcase_42 AC 53 ms
63,544 KB
testcase_43 AC 55 ms
65,844 KB
testcase_44 AC 62 ms
72,272 KB
testcase_45 AC 53 ms
65,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env PyPy3

from collections import Counter, defaultdict, deque
import itertools
import re
import math
from functools import reduce
import operator
import bisect
from heapq import *
import functools

mod=10 ** 9 + 7

import sys
input = sys.stdin.readline

h,w=map(int,input().split())
s = [input().rstrip() for _ in range(h)]
li = []
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            li.append((i,j))
if len(li) % 2:
    print('NO')
else:
    for i in range(1,len(li)):
        px = li[i][0] - li[0][0]
        py = li[i][1] - li[0][1]
        ns = [[0] * w for _ in range(h)]
        flg = 0
        for j in range(h):
            for k in range(w):
                if s[j][k] == '#':
                    if ns[j][k]:
                        continue
                    ns[j][k] = 1
                    if 0 <= j + px < h and 0 <= k + py < w:
                        if s[j + px][k + py] == '#' and ns[j + px][k + py] == 0:
                            ns[j + px][k + py] = 1
                        else:
                            flg = 1
                            break
                    else:
                        flg = 1
                        break
            if flg:
                break
        if not flg:
            print('YES')
            exit()
    print('NO')
0