結果
問題 | No.168 ものさし |
ユーザー | 6soukiti29 |
提出日時 | 2017-10-19 22:43:01 |
言語 | Nim (2.0.2) |
結果 |
AC
|
実行時間 | 63 ms / 2,000 ms |
コード長 | 2,569 bytes |
コンパイル時間 | 3,071 ms |
コンパイル使用メモリ | 68,412 KB |
実行使用メモリ | 13,648 KB |
最終ジャッジ日時 | 2023-09-12 15:19:15 |
合計ジャッジ時間 | 4,551 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 21 ms
9,420 KB |
testcase_01 | AC | 3 ms
5,392 KB |
testcase_02 | AC | 2 ms
5,396 KB |
testcase_03 | AC | 2 ms
5,432 KB |
testcase_04 | AC | 2 ms
5,464 KB |
testcase_05 | AC | 3 ms
5,532 KB |
testcase_06 | AC | 2 ms
5,572 KB |
testcase_07 | AC | 2 ms
5,352 KB |
testcase_08 | AC | 2 ms
5,388 KB |
testcase_09 | AC | 3 ms
5,880 KB |
testcase_10 | AC | 5 ms
6,260 KB |
testcase_11 | AC | 19 ms
9,268 KB |
testcase_12 | AC | 47 ms
13,596 KB |
testcase_13 | AC | 63 ms
13,452 KB |
testcase_14 | AC | 56 ms
11,508 KB |
testcase_15 | AC | 2 ms
5,476 KB |
testcase_16 | AC | 3 ms
5,728 KB |
testcase_17 | AC | 5 ms
6,000 KB |
testcase_18 | AC | 6 ms
6,688 KB |
testcase_19 | AC | 57 ms
13,508 KB |
testcase_20 | AC | 57 ms
13,612 KB |
testcase_21 | AC | 61 ms
13,512 KB |
testcase_22 | AC | 59 ms
13,648 KB |
コンパイルメッセージ
/home/judge/data/code/Main.nim(24, 25) Warning: Number of spaces around '<=' is not consistent [Spacing]
ソースコード
import sequtils,strutils,math type priorityQue[I:static[int];T:tuple] = array[I + 1,T] item = tuple[cost: int,ID : int] 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]] 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] var pq : priorityQue[1_000_001, item] t : item N = stdin.readline.parseInt x, y : int nodes = newSeq[array[2, int]](0) mincos : array[1000, int] hyou : array[1000, array[1000, int64]] flag : array[1000, bool] for n in 0..<N: (x, y) = stdin.readline.split.map(parseInt) for i in 0..<n: var r : float64 a = abs(nodes[i][0] - x).int64 b = abs(nodes[i][1] - y).int64 l : int64 if a < b: (a, b) = (b, a) if a == 0: r = 0 else: r = a.float64 * sqrt(1 + (b.int / a.int) * (b.int / a.int)) r = r / 10 r = round(r + 1e-12, 10).ceil l = r.int64 * 10 while l * l < a * a + b * b: l += 10 hyou[n][i] = l hyou[i][n] = l nodes.add([x, y]) mincos[n] = int.high pq.push((0, 0)) mincos[0] = 0 while pq.size > 0: t = pq.pop flag[t.ID] = true if t.ID == N - 1: break for i,c in hyou[t.ID]: if flag[i]: continue if mincos[i] > max(hyou[i][t.ID].int, mincos[t.ID]): mincos[i] = max(hyou[i][t.ID].int, mincos[t.ID]) pq.push(( -mincos[i], i)) echo mincos[N - 1]