結果

問題 No.20 砂漠のオアシス
ユーザー むらためむらため
提出日時 2019-02-05 09:57:34
言語 Nim
(2.0.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 670 bytes
コンパイル時間 928 ms
コンパイル使用メモリ 56,892 KB
最終ジャッジ日時 2023-09-14 03:30:54
合計ジャッジ時間 1,555 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
/home/judge/data/code/Main.nim(2, 10) Warning: Deprecated since v1.5; Use auto instead.; any is deprecated [Deprecated]
/home/judge/data/code/Main.nim(7, 42) Error: undeclared identifier: 'newHeapQueue'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (3, 2): 'heapqueue' [module declared in /home/judge/data/code/Main.nim(1, 26)]
 (3, 4): 'initHeapQueue' [proc declared in /nim-1.6.12/lib/pure/collections/heapqueue.nim(54, 6)]
 (3, 4): 'toHeapQueue' [proc declared in /nim-1.6.12/lib/pure/collections/heapqueue.nim(139, 6)]

ソースコード

diff #

import sequtils,strutils,heapqueue
proc r():any=stdin.readLine.split.map parseInt
let(n,v,ox,oy)=(let t=r();(t[0],t[1],t[3]-1,t[2]-1))
let L=newSeqWith(n,r())
type F=tuple[v,x,y:int]
proc T(sx,sy,sv,c:int)=
 var(C,O)=(newSeqWith(n,newSeq[bool](n)),newHeapQueue[F]())
 O.push (-sv,sx,sy)
 while O.len>0:
  var(v,x,y)=O.pop()
  v= -v
  if C[x][y]:continue
  C[x][y]=true
  if c==1 and x==ox and y==oy:(T(x,y,v*2,0);continue)
  for d in[(0,1),(1,0),(0,-1),(-1,0)]:
   let(nx,ny)=(d[0]+x,d[1]+y)
   if nx<0 or ny<0 or nx>=n or ny>=n :continue
   if v-L[nx][ny]<=0 or C[nx][ny]:continue
   O.push (-v+L[nx][ny],nx,ny)
   if nx==n-1 and ny==n-1:quit "YES",0
T 0,0,v,1
echo"NO"
0