結果
問題 | No.2641 draw X |
ユーザー | chineristAC |
提出日時 | 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 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
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)