結果
| 問題 |
No.134 走れ!サブロー君
|
| コンテスト | |
| ユーザー |
6soukiti29
|
| 提出日時 | 2017-09-07 21:30:48 |
| 言語 | Nim (2.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,687 bytes |
| コンパイル時間 | 867 ms |
| コンパイル使用メモリ | 66,432 KB |
| 最終ジャッジ日時 | 2024-11-14 20:15:00 |
| 合計ジャッジ時間 | 1,261 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(50, 32) Error: type mismatch: got 'seq[int]' for 'map(split(readLine(stdin), {' ', '\t', '\v', '\r', '\n', '\f'}, -1), parseInt)' but expected 'tuple'
ソースコード
import sequtils,strutils,strscans,math
type
priorityQue[I:static[int];T:tuple] = array[I + 1,T]
item = tuple[p : int,cost : float64, weight : float64, bitflag : int]
proc push[T](A:var priorityQue; b: T)=
const key = 1
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 = 1
result = A[1]
A[1] = A[A[0][0]]
var a : item
A[A[0][0]] = a
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]
type
zahyou = tuple[x : int, y : int, w : float64]
var
ax,ay,x,y : int
w,SW : float64
N : int
s : string
mintime : array[15, array[1 shl 14, float64]]
PQ : priorityQue[500000, item]
(ax, ay) = stdin.readline.split.map(parseInt)
N = stdin.readline.parseInt
var tizu = newSeq[zahyou](N + 1)
for n in 1..N:
s = stdin.readline
discard scanf(s,"$i $i $f",x, y, w)
tizu[n] = (x - ax, y - ay, w)
SW += w
var
t,t2 : item
p,p2 : zahyou
t = (0, 0.0, SW, 1)
PQ.push(t)
while PQ.size > 0:
t = PQ.pop()
var
b = t.bitflag
T : float64 = (t.weight + 100) / 120
for k in 1..N:
if ((1 shl k) and b) == 0:
p2 = tizu[k]
p = tizu[t.p]
var d = (abs(p2.x - p.x) + abs(p2.y - p.y)).float64
t2 = (k, t.cost - T * d - p2.w , t.weight - p2.w, b or (1 shl k))
if countBits32(t2.bitflag.int32) == N + 1:
t2.cost -= (abs(p2.x) + abs(p2.y)).float64 * (100 / 120)
if mintime[k][t2.bitflag] == 0 or mintime[k][t2.bitflag] < t2.cost:
mintime[k][t2.bitflag] = t2.cost
PQ.push(t2)
var ans : float64 = Inf
for i in 1..N:
if mintime[i][(1 shl (N + 1)) - 1] == 0:
continue
ans = min(ans, - mintime[i][(1 shl (N + 1)) - 1])
echo ans
6soukiti29