結果

問題 No.367 ナイトの転身
ユーザー むらためむらため
提出日時 2019-02-05 12:51:37
言語 Nim
(2.0.2)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 630 bytes
コンパイル時間 3,318 ms
コンパイル使用メモリ 71,836 KB
実行使用メモリ 65,544 KB
最終ジャッジ日時 2023-09-14 03:33:05
合計ジャッジ時間 4,832 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
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 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,strutils
var
 hw=stdin.readLine.split.map parseInt
 h=hw[0]
 w=hw[1]
 M=newSeqWith h:stdin.readLine
 g,o:int
 qi=0
 q=newSeq[(int,int,int,int)]()
 D=newSeqWith w:newSeqWith h:[9999,9999]
for y in 0..<h:(for x in 0..<w:(if M[y][x]=='S':(D[x][y][0]=0;q&=(x,y,1,0));if M[y][x]=='G':(g=x;o=y)))
while q.len-qi>0:(let(x,y,k,f)=q[qi];qi+=1;for d in[@[(1,1),(-1,-1),(1,-1),(-1,1)],@[(1,2),(2,1),(-1,-2),(-2,-1),(-1,2),(-2,1),(1,-2),(2,-1)]][k]:(let(n,m)=(x+d[0],y+d[1]);if n in 0..<w and m in 0..<h:(if n==g and m==o:quit $(f+1),0;var z=k;if M[m][n]=='R':z=1-k;if D[n][m][z]>f+1:(D[n][m][z]=f+1;q&=(n,m,z,f+1)))))
echo -1
0