結果
| 問題 | No.20 砂漠のオアシス |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-12 15:55:32 |
| 言語 | Nim (2.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,885 bytes |
| コンパイル時間 | 938 ms |
| コンパイル使用メモリ | 75,340 KB |
| 最終ジャッジ日時 | 2024-11-14 21:44:42 |
| 合計ジャッジ時間 | 1,330 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
/home/judge/data/code/Main.nim(30, 15) Error: undeclared identifier: 'newHeapQueue' candidates (edit distance, scope distance); see '--spellSuggest': (3, 2): 'heapqueue' (3, 4): 'initHeapQueue' (3, 4): 'toHeapQueue'
ソースコード
{.checks: off, optimization: speed.}
import sequtils,strutils,strscans,algorithm,math,sugar,sets,tables,macros
import heapqueue
macro unpack*(rhs: seq,cnt: static[int]): auto =
let t = genSym(); result = quote do:(let `t` = `rhs`;())
for i in 0..<cnt: result[1].add(quote do:`t`[`i`])
template get*():string = stdin.readLine()
template times*(n:int,body) = (for _ in 0..<n: body)
template `max=`*(x,y)= (x = max(x,y))
template `min=`*(x,y)= (x = min(x,y))
proc transpose*[T](mat:seq[seq[T]]):seq[seq[T]] =
result = newSeqWith(mat[0].len,newSeq[T](mat.len))
for x,xs in mat: (for y,ys in xs:result[y][x] = mat[x][y])
const dxdy4 :seq[tuple[x,y:int]] = @[(0,1),(1,0),(0,-1),(-1,0)]
# 0以下で死亡 / V - Lxy => Oasis(v *= 2,once)
# N <= 200, V <= 500, Lxy <= 9
# x:N * y:N * use:2 => V
# 最短でゴール or 最短でオアシス +最短でゴールのみ
let
(N,V,oax,oay) = get().split().map(parseInt).unpack(4)
L = newSeqWith(N,get().strip().split().map(parseInt)).transpose()
(ox,oy) = (oax-1,oay-1)
############## 二段階にわける #####################
type field = tuple[x,y,v:int]
proc `<`(x,y:field):bool = (x.v > y.v)
proc twoFactorDijkestra(sx,sy,sv:int,checkOasis:bool = true):void =
var closed = newSeqWith(N,newSeqWith(N,false))
var opens = newHeapQueue[field]()
opens.push((sx,sy,sv))
while opens.len() > 0:
let (x,y,v) = opens.pop()
if closed[x][y] : continue
closed[x][y] = true
if checkOasis and x == ox and y == oy:
twoFactorDijkestra(x,y,v * 2,false)
continue
for d in dxdy4:
let (nx,ny) = (d.x + x,d.y + y)
if nx < 0 or ny < 0 or nx >= N or ny >= N : continue
var n_v = v - L[nx][ny]
if n_v <= 0 : continue
if not closed[nx][ny]:
opens.push((nx,ny,n_v))
if nx == N-1 and ny == N-1:
echo "YES"
quit()
twoFactorDijkestra(0,0,V)
echo "NO"