結果

問題 No.2641 draw X
ユーザー chineristACchineristAC
提出日時 2024-02-19 23:00:11
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 2,912 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 81,976 KB
実行使用メモリ 94,956 KB
最終ジャッジ日時 2024-09-29 02:42:45
合計ジャッジ時間 7,317 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
64,176 KB
testcase_01 AC 47 ms
56,828 KB
testcase_02 AC 46 ms
58,044 KB
testcase_03 AC 50 ms
57,432 KB
testcase_04 AC 47 ms
58,240 KB
testcase_05 AC 46 ms
57,408 KB
testcase_06 AC 48 ms
57,020 KB
testcase_07 AC 45 ms
57,900 KB
testcase_08 AC 48 ms
57,012 KB
testcase_09 AC 46 ms
56,912 KB
testcase_10 AC 46 ms
57,496 KB
testcase_11 AC 46 ms
57,792 KB
testcase_12 AC 45 ms
57,428 KB
testcase_13 AC 45 ms
56,648 KB
testcase_14 AC 46 ms
57,808 KB
testcase_15 AC 279 ms
94,196 KB
testcase_16 AC 394 ms
94,956 KB
testcase_17 AC 47 ms
57,732 KB
testcase_18 AC 46 ms
56,860 KB
testcase_19 AC 48 ms
56,900 KB
testcase_20 AC 161 ms
79,516 KB
testcase_21 AC 180 ms
80,604 KB
testcase_22 AC 163 ms
79,308 KB
testcase_23 AC 167 ms
80,316 KB
testcase_24 AC 134 ms
78,788 KB
testcase_25 AC 140 ms
79,120 KB
testcase_26 AC 185 ms
80,584 KB
testcase_27 AC 163 ms
78,716 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import permutations
from heapq import heappop,heappush
from collections import deque
import random
import bisect

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

H,W = mi()
S = [input() for i in range(H)]

maximum_r = [[H+W]*W for i in range(H)]

for s in range(-(W-1),H):
    tmp = 0
    for j in range(0,W):
        i = s + j
        if not 0 <= i < H:
            continue

        if S[i][j] == "#":
            maximum_r[i][j] = min(maximum_r[i][j],tmp)
            tmp += 1
        else:
            maximum_r[i][j] = -1
            tmp = 0
    
    tmp = 0
    for j in range(W)[::-1]:
        i = s + j
        if not 0 <= i < H:
            continue

        if S[i][j] == "#":
            maximum_r[i][j] = min(maximum_r[i][j],tmp)
            tmp += 1
        else:
            maximum_r[i][j] = -1
            tmp = 0


for t in range(H+W-1):
    tmp = 0
    for j in range(W)[::-1]:
        i = t - j
        if not 0 <= i < H:
            continue

        if S[i][j] == "#":
            maximum_r[i][j] = min(maximum_r[i][j],tmp)
            tmp += 1
        else:
            maximum_r[i][j] = 0
            tmp = 0
    
    tmp = 0
    for j in range(W):
        i = t - j
        if not 0 <= i < H:
            continue

        if S[i][j] == "#":
            maximum_r[i][j] = min(maximum_r[i][j],tmp)
            tmp += 1
        else:
            maximum_r[i][j] = -1
            tmp = 0

final = [[0]*W for i in range(H)]
for s in range(-(W-1),H):
    tmp = -1
    for j in range(0,W):
        i = s + j
        if not 0 <= i < H:
            continue
        
        if maximum_r[i][j] > 0:
            tmp = max(tmp-1,maximum_r[i][j])
        else:
            tmp = tmp - 1
        if tmp >= 0:
            final[i][j] = 1

    tmp = 0
    for j in range(W)[::-1]:
        i = s + j
        if not 0 <= i < H:
            continue

        if maximum_r[i][j] > 0:
            tmp = max(tmp-1,maximum_r[i][j])
        else:
            tmp = tmp - 1
        if tmp >= 0:
            final[i][j] = 1

for t in range(H+W-1):
    tmp = 0
    for j in range(W)[::-1]:
        i = t - j
        if not 0 <= i < H:
            continue

        if maximum_r[i][j] > 0:
            tmp = max(tmp-1,maximum_r[i][j])
        else:
            tmp = tmp - 1
        if tmp >= 0:
            final[i][j] = 1
    
    tmp = 0
    for j in range(W):
        i = t - j
        if not 0 <= i < H:
            continue

        if maximum_r[i][j] > 0:
            tmp = max(tmp-1,maximum_r[i][j])
        else:
            tmp = tmp - 1
        if tmp >= 0:
            final[i][j] = 1

#for i in range(H):
    #print(maximum_r[i])
#print()
#for i in range(H):
    #print(final[i])
ans = "Yes"
for i in range(H):
    for j in range(W):
        if S[i][j] == "#" and not final[i][j]:
            ans = "No"
print(ans)
0