結果

問題 No.323 yuki国
ユーザー LeonardoneLeonardone
提出日時 2015-12-16 23:47:50
言語 Python2
(2.7.18)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,439 bytes
コンパイル時間 696 ms
コンパイル使用メモリ 6,728 KB
実行使用メモリ 6,148 KB
最終ジャッジ日時 2023-10-14 11:22:17
合計ジャッジ時間 2,640 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,832 KB
testcase_01 AC 10 ms
5,952 KB
testcase_02 AC 10 ms
5,828 KB
testcase_03 AC 10 ms
5,848 KB
testcase_04 AC 10 ms
5,968 KB
testcase_05 AC 10 ms
5,908 KB
testcase_06 AC 10 ms
5,964 KB
testcase_07 AC 10 ms
5,896 KB
testcase_08 AC 10 ms
5,816 KB
testcase_09 AC 11 ms
5,892 KB
testcase_10 AC 10 ms
5,816 KB
testcase_11 AC 10 ms
5,816 KB
testcase_12 AC 10 ms
5,880 KB
testcase_13 AC 14 ms
5,868 KB
testcase_14 AC 10 ms
5,968 KB
testcase_15 AC 39 ms
6,148 KB
testcase_16 AC 13 ms
5,936 KB
testcase_17 AC 26 ms
5,976 KB
testcase_18 AC 13 ms
5,888 KB
testcase_19 AC 10 ms
5,832 KB
testcase_20 AC 16 ms
6,016 KB
testcase_21 AC 10 ms
5,948 KB
testcase_22 AC 16 ms
5,924 KB
testcase_23 AC 10 ms
5,980 KB
testcase_24 AC 18 ms
6,012 KB
testcase_25 AC 10 ms
5,816 KB
testcase_26 AC 13 ms
5,920 KB
testcase_27 AC 10 ms
5,828 KB
testcase_28 AC 12 ms
5,872 KB
testcase_29 AC 13 ms
6,020 KB
testcase_30 WA -
testcase_31 AC 10 ms
5,884 KB
testcase_32 WA -
testcase_33 AC 10 ms
5,828 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 10 ms
5,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 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 ansNo
        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 m[gi + 1][gj] == pCh:
            gplus = True
        if gj + 1 < w and m[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()
0