結果
問題 | No.134 走れ!サブロー君 |
ユーザー |
![]() |
提出日時 | 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,mathtypepriorityQue[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 = 1A[0][0] += 1A[A[0][0]] = b # A[0][0]はsize、最大のIndexvar 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 2proc pop(A: var priorityQue):item =const key = 1result = A[1]A[1] = A[A[0][0]]var a : itemA[A[0][0]] = aA[0][0] -= 1var index = 1while 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 * 2elif A[index][key] < A[index * 2 + 1][key]:(A[index],A[index * 2 + 1]) = (A[index * 2 + 1],A[index])index = index * 2 + 1else:breakelif index * 2 <= A[0][0]:if A[index][key] < A[index * 2][key]:(A[index],A[index * 2]) = (A[index * 2],A[index])breakelse:breakproc size(A : priorityQue):int=return A[0][0]typezahyou = tuple[x : int, y : int, w : float64]varax,ay,x,y : intw,SW : float64N : ints : stringmintime : array[15, array[1 shl 14, float64]]PQ : priorityQue[500000, item](ax, ay) = stdin.readline.split.map(parseInt)N = stdin.readline.parseIntvar tizu = newSeq[zahyou](N + 1)for n in 1..N:s = stdin.readlinediscard scanf(s,"$i $i $f",x, y, w)tizu[n] = (x - ax, y - ay, w)SW += wvart,t2 : itemp,p2 : zahyout = (0, 0.0, SW, 1)PQ.push(t)while PQ.size > 0:t = PQ.pop()varb = t.bitflagT : float64 = (t.weight + 100) / 120for 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)).float64t2 = (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.costPQ.push(t2)var ans : float64 = Inffor i in 1..N:if mintime[i][(1 shl (N + 1)) - 1] == 0:continueans = min(ans, - mintime[i][(1 shl (N + 1)) - 1])echo ans