結果

問題 No.179 塗り分け
ユーザー mkawa2mkawa2
提出日時 2019-12-30 17:12:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 187 ms / 3,000 ms
コード長 1,587 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 11,008 KB
実行使用メモリ 30,196 KB
最終ジャッジ日時 2023-09-30 21:16:49
合計ジャッジ時間 8,504 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
30,052 KB
testcase_01 AC 137 ms
29,976 KB
testcase_02 AC 140 ms
30,104 KB
testcase_03 AC 135 ms
30,084 KB
testcase_04 AC 139 ms
29,868 KB
testcase_05 AC 138 ms
29,988 KB
testcase_06 AC 135 ms
29,892 KB
testcase_07 AC 136 ms
30,100 KB
testcase_08 AC 137 ms
29,976 KB
testcase_09 AC 136 ms
30,016 KB
testcase_10 AC 144 ms
30,156 KB
testcase_11 AC 139 ms
30,096 KB
testcase_12 AC 187 ms
29,996 KB
testcase_13 AC 138 ms
30,008 KB
testcase_14 AC 138 ms
30,112 KB
testcase_15 AC 138 ms
29,984 KB
testcase_16 AC 136 ms
30,104 KB
testcase_17 AC 136 ms
29,992 KB
testcase_18 AC 139 ms
30,036 KB
testcase_19 AC 138 ms
30,088 KB
testcase_20 AC 157 ms
30,124 KB
testcase_21 AC 142 ms
30,132 KB
testcase_22 AC 148 ms
30,040 KB
testcase_23 AC 136 ms
30,088 KB
testcase_24 AC 144 ms
30,132 KB
testcase_25 AC 138 ms
30,080 KB
testcase_26 AC 139 ms
30,132 KB
testcase_27 AC 148 ms
30,100 KB
testcase_28 AC 139 ms
30,192 KB
testcase_29 AC 155 ms
30,196 KB
testcase_30 AC 142 ms
29,980 KB
testcase_31 AC 159 ms
30,104 KB
testcase_32 AC 140 ms
30,056 KB
testcase_33 AC 159 ms
30,120 KB
testcase_34 AC 142 ms
30,136 KB
testcase_35 AC 160 ms
30,168 KB
testcase_36 AC 135 ms
29,984 KB
testcase_37 AC 134 ms
30,124 KB
testcase_38 AC 135 ms
29,968 KB
testcase_39 AC 135 ms
30,120 KB
testcase_40 AC 135 ms
30,016 KB
testcase_41 AC 134 ms
29,884 KB
testcase_42 AC 134 ms
30,020 KB
testcase_43 AC 141 ms
30,108 KB
testcase_44 AC 147 ms
30,016 KB
testcase_45 AC 137 ms
30,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import *
from bisect import *
# from math import *
from collections import *
from heapq import *
from random import *
from decimal import *
import numpy as np
import sys
import copy

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    def check(di,dj):
        for i in range(h):
            for j in range(w):
                if t[i][j] and first[i][j]:
                    if not 0<=i+di<h:return False
                    if not 0<=j+dj<w:return False
                    if not t[i+di][j+dj]:return False
                    first[i+di][j+dj]=False
        return True

    h, w = MI()
    t = [[c == "#" for c in input()] for _ in range(h)]
    si,sj=-1,-1
    for i in range(h):
        for j in range(w):
            if t[i][j]:
                if si==-1:
                    si,sj=i,j
                else:
                    first=[[True]*w for _ in range(h)]
                    if check(i-si,j-sj):
                        print("YES")
                        exit()
    print("NO")
main()
0