結果
| 問題 | No.323 yuki国 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-16 23:44:38 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,440 bytes |
| 記録 | |
| コンパイル時間 | 287 ms |
| コンパイル使用メモリ | 77,568 KB |
| 最終ジャッジ日時 | 2025-12-03 18:38:58 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 21 WA * 5 RE * 6 |
ソースコード
# coding: utf-8
# yukicoder My Practice
# author: Leonardone @ NEETSDKASU
def gis():
return map(int, raw_input().split())
def arr2d(h,w):
return [[0] * w for _ in xrange(h)]
def solve():
ansYes = "Yes"
ansNo = "No"
pCh = "*"
mCh = "."
(h,w) = gis()
(a, si, sj) = start = gis()
(b, gi, gj) = goal = gis()
m = [raw_input() for _ in xrange(h)]
l = abs(si - gi) + abs(sj - gj)
if l % 2 == 0 and a % 2 != b % 2:
print ansNo
return
if l % 2 == 1 and a % 2 == b % 2:
print ansNo
return
minus = arr2d(h,w)
plus = arr2d(h,w)
def chk(rch2, c, y2, x2):
if m[y2][x2] == pCh:
if plus[y2][x2] == 0:
rch2.append([c + 1, y2, x2])
plus[y2][x2] = 1
elif c > 1 and minus[y2][x2] < c - 1:
rch2.append([c - 1, y2, x2])
minus[y2][x2] = c - 1
rch1 = [start]
while len(rch1) > 0:
rch2 = []
for (c,y,x) in rch1:
if x > 0:
chk(rch2, c, y, x - 1)
if y > 0:
chk(rch2, c, y - 1, x)
if x + 1 < w:
chk(rch2, c, y, x + 1)
if y + 1 < h:
chk(rch2, c, y + 1, x)
rch1 = rch2
mcount = 0
for ml in m:
mcount += ml.count(mCh)
if mcount < 2 and a + l > b:
print ansYes
return
gplus = False
if m[gi][gj] == pCh:
if gi > 0 and m[gi - 1][gj] == pCh:
gplus = True
if gj > 0 and m[gi][gj - 1] == pCh:
gplus = True
if gi + 1 < h and g[gi + 1][gj] == pCh:
gplus = True
if gj + 1 < w and g[gi][gj + 1] == pCh:
gplus =True
if gplus:
print ansYes
return
if plus[gi][gj] > 0:
print ansYes
return
flagP = False
for i in xrange(h):
for j in xrange(1,w):
if plus[i][j] > 0 and plus[i][j - 1] > 0:
flagP = True
for j in xrange(w):
for i in xrange(1,h):
if plus[i][j] > 0 and plus[i - 1][j] > 0:
flagP = True
if flagP:
if m[gi][gj] == pCh and gplus == False:
print ansNo
return
print ansYes
return
if minus[gi][gj] > 0:
print ansYes
return
print ansNo
solve()