結果

問題 No.2641 draw X
ユーザー chineristACchineristAC
提出日時 2024-02-19 23:17:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 424 ms / 2,000 ms
コード長 3,157 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 82,852 KB
実行使用メモリ 95,256 KB
最終ジャッジ日時 2024-09-29 02:59:31
合計ジャッジ時間 9,117 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
58,696 KB
testcase_01 AC 46 ms
57,968 KB
testcase_02 AC 50 ms
57,360 KB
testcase_03 AC 47 ms
57,012 KB
testcase_04 AC 47 ms
57,668 KB
testcase_05 AC 48 ms
57,096 KB
testcase_06 AC 44 ms
58,256 KB
testcase_07 AC 44 ms
58,088 KB
testcase_08 AC 46 ms
56,932 KB
testcase_09 AC 47 ms
57,372 KB
testcase_10 AC 45 ms
57,692 KB
testcase_11 AC 45 ms
56,888 KB
testcase_12 AC 46 ms
58,100 KB
testcase_13 AC 45 ms
56,696 KB
testcase_14 AC 47 ms
58,488 KB
testcase_15 AC 252 ms
94,464 KB
testcase_16 AC 379 ms
95,256 KB
testcase_17 AC 47 ms
57,960 KB
testcase_18 AC 47 ms
57,196 KB
testcase_19 AC 47 ms
56,896 KB
testcase_20 AC 170 ms
79,324 KB
testcase_21 AC 194 ms
81,592 KB
testcase_22 AC 174 ms
79,776 KB
testcase_23 AC 181 ms
80,872 KB
testcase_24 AC 124 ms
78,688 KB
testcase_25 AC 139 ms
78,908 KB
testcase_26 AC 193 ms
81,520 KB
testcase_27 AC 159 ms
79,468 KB
testcase_28 AC 166 ms
84,248 KB
testcase_29 AC 243 ms
91,348 KB
testcase_30 AC 236 ms
89,296 KB
testcase_31 AC 216 ms
85,380 KB
testcase_32 AC 266 ms
90,868 KB
testcase_33 AC 305 ms
91,888 KB
testcase_34 AC 234 ms
85,468 KB
testcase_35 AC 227 ms
84,680 KB
testcase_36 AC 321 ms
93,752 KB
testcase_37 AC 424 ms
95,216 KB
testcase_38 AC 337 ms
93,316 KB
testcase_39 AC 359 ms
94,832 KB
testcase_40 AC 423 ms
94,688 KB
testcase_41 AC 307 ms
92,740 KB
testcase_42 AC 371 ms
93,512 KB
testcase_43 AC 356 ms
93,188 KB
権限があれば一括ダウンロードができます

ソースコード

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(max(0,-s),min(W,H-s)):
        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(max(0,-s),min(W,H-s))[::-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
    """
    0 <= t-j < H
    t-H < j <= t
    max(0,t-H+1) <= j < min(t+1,W)
    """
    for j in range(max(0,t-H+1),min(t+1,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(max(0,t-H+1),min(t+1,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(max(0,-s),min(W,H-s)):
        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(max(0,-s),min(W,H-s))[::-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(max(0,t-H+1),min(t+1,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(max(0,t-H+1),min(t+1,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