結果

問題 No.323 yuki国
ユーザー LeonardoneLeonardone
提出日時 2015-12-16 06:14:16
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 1,573 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 11,280 KB
実行使用メモリ 15,612 KB
最終ジャッジ日時 2023-10-14 10:35:09
合計ジャッジ時間 4,925 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 86 ms
15,220 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 88 ms
15,180 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 85 ms
15,288 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 95 ms
15,612 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 89 ms
15,332 KB
testcase_31 AC 85 ms
15,160 KB
testcase_32 AC 86 ms
15,140 KB
testcase_33 AC 85 ms
15,184 KB
testcase_34 AC 84 ms
15,332 KB
testcase_35 AC 85 ms
15,084 KB
testcase_36 AC 87 ms
15,248 KB
testcase_37 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:50: warning: mismatched indentations at 'elsif' with 'if' at 45
Main.rb:53: warning: mismatched indentations at 'end' with 'if' at 45
Syntax OK

ソースコード

diff #

#! ruby
# yukicoder My Practice
# author: Leonardone @ NEETSDKASU

def gs() gets.chomp end
def gi() gets.to_i end
def gss() gets.chomp.split end
def gis() gss.map(&:to_i) end
def nmapf(n,f) n.times.map{ __send__ f } end
def arr2d(h,w,v=0) h.times.map{[v] * w} end
def ngs(n) nmapf n,:gs end
def ngi(n) nmapf n,:gi end
def ngss(n) nmapf n,:gss end
def ngis(n) nmapf n,:gis end

require 'set'

H, W = gis
A, Si, Sj = Start = gis
B, Gi, Gj = Goal = gis

$M = ngs H

AnsYes = 'Yes'
AnsNo = 'No'

l = (Si - Gi).abs + (Sj - Gj).abs

if l.even? && (A.even? == B.even?)
    puts AnsNo
    exit
end

if l.odd? && (A.even? != B.even?)
    puts AnsNo
    exit
end

$minus = arr2d H,W
$plus = arr2d H,W

$minus[Si][Sj] = A

def chk(rch2, c, y2, x2)
   if $M[y2][x2] == '*'
        if $plus[y2][x2] == 0
            rch2 << [c + 1, y2, x2]
            $plus[y2][x2] = 1
        end
    elsif c > 1 && $minus[y2][x2] < c - 1
        rch2 << [c - 1, y2, x2]
        $minus[y2][x2] = c - 1
    end
end

rch1 = [Start]
while !rch1.empty?
    rch2 = []
    rch1.each do |c,y,x|
        chk rch2, c, y, x - 1 if x > 0
        chk rch2, c, y - 1, x if y > 0
        chk rch2, c, y, x + 1 if x + 1 < W
        chk rch2, c, y + 1, x if y + 1 < H
    end
    rch1 = rch2
end

H.times do |i|
    (1...W).each do |j|
        if $plus[i][j] > 0 && $plus[i][j - 1] > 0
            puts AnsYes
            exit
        end
    end
end

W.times do |j|
    (1...H).each do |i|
        if $plus[i][j] > 0 && $plus[i - 1][j] > 0
            puts AnsYes
            exit
        end
    end
end

puts AnsNo
0