結果
| 問題 | No.20 砂漠のオアシス |
| コンテスト | |
| ユーザー |
6soukiti29
|
| 提出日時 | 2017-07-26 23:39:03 |
| 言語 | Nim (2.2.6) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,718 bytes |
| 記録 | |
| コンパイル時間 | 1,014 ms |
| コンパイル使用メモリ | 64,944 KB |
| 最終ジャッジ日時 | 2024-11-15 04:45:43 |
| 合計ジャッジ時間 | 1,421 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
/home/judge/data/code/Main.nim(23, 25) Warning: Number of spaces around '<=' is not consistent [Spacing]
/home/judge/data/code/Main.nim(51, 35) Error: type mismatch: got 'seq[int]' for 'map(split(readLine(stdin), {' ', '\t', '\v', '\r', '\n', '\f'}, -1), parseInt)' but expected 'tuple'
ソースコード
import sequtils,strutils
type
zahyou = tuple[y : int, x : int]
type
priorityQue[I:static[int];T:tuple] = array[I + 1,T]
item = tuple[cost: int,ID : zahyou]
proc push[T](A:var priorityQue; b: T;)=
const key = 0
A[0][0] += 1
A[A[0][0]] = b # A[0][0]はsize、最大のIndex
var index = A[0][0]
while index > 1 and A[index][key] > A[index div 2][key]:
(A[index],A[index div 2]) = (A[index div 2],A[index])
index = index div 2
proc pop(A: var priorityQue):item = #戻り値を書き換える
const key = 0
result = A[1]
A[1] = A[A[0][0]]
A[A[0][0]] = (0,(0,0))
A[0][0] -= 1
var index = 1
while index * 2 <= A[0][0]:
if index * 2 + 1<= A[0][0]:
if A[index][key] < A[index * 2][key] and A[index * 2 + 1][key] <= A[index * 2][key]:
(A[index],A[index * 2]) = (A[index * 2],A[index])
index = index * 2
elif A[index][key] < A[index * 2 + 1][key]:
(A[index],A[index * 2 + 1]) = (A[index * 2 + 1],A[index])
index = index * 2 + 1
else:
break
elif index * 2 <= A[0][0]:
if A[index][key] < A[index * 2][key]:
(A[index],A[index * 2]) = (A[index * 2],A[index])
break
else:
break
proc size(A : priorityQue):int=
return A[0][0]
var
N,V,Ox,Oy : int
sabaku : array[202,array[202,int]]
line : seq[int]
D = [[1,0],[0,1],[-1,0],[0,-1]]
startcost : seq[seq[int]]
gorlcost : seq[seq[int]]
p : zahyou
r : item
(N,V,Ox,Oy) = stdin.readline.split.map(parseInt)
for i in 0..201:
for j in 0..201:
sabaku[i][j] = 1000000
for i in 0..<N:
line = stdin.readline.strip.split.map(parseInt)
for j in 0..<N:
sabaku[i + 1][j + 1] = line[j]
for i in 0..1:
var
S = newSeqWith(N + 2,newSeqWith(N + 2,-1000000))
pq : priorityQue[40000,item]
if i == 0:
p = (1,1)
pq.push((0,p))
S[1][1] = 0
else:
p = (N,N)
pq.push((-sabaku[N][N],p))
S[N][N] = -sabaku[N][N]
while pq.size > 0:
r = pq.pop
p = r.ID
if S[p.y][p.x] > r.cost:
continue
for d in D:
if S[p.y + d[0]][p.x + d[1]] < r.cost - sabaku[p.y + d[0]][p.x + d[1]]:
S[p.y + d[0]][p.x + d[1]] = r.cost - sabaku[p.y + d[0]][p.x + d[1]]
pq.push((S[p.y + d[0]][p.x + d[1]],(p.y + d[0],p.x + d[1])))
if i == 0:
startcost = S
else:
gorlcost = S
var Vo = V + startcost[Oy][Ox]
Vo *= 2
Vo += sabaku[Oy][Ox]
if Vo > -gorlcost[Oy][Ox] or -startcost[N][N] < V:
echo "YES"
else:
echo "NO"
6soukiti29