結果
問題 | No.168 ものさし |
ユーザー | 6soukiti29 |
提出日時 | 2017-10-19 22:35:53 |
言語 | Nim (2.0.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,542 bytes |
コンパイル時間 | 3,209 ms |
コンパイル使用メモリ | 68,348 KB |
実行使用メモリ | 13,576 KB |
最終ジャッジ日時 | 2023-09-12 15:20:33 |
合計ジャッジ時間 | 4,825 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 23 ms
9,352 KB |
testcase_01 | WA | - |
testcase_02 | AC | 3 ms
5,436 KB |
testcase_03 | AC | 3 ms
5,448 KB |
testcase_04 | AC | 2 ms
5,452 KB |
testcase_05 | WA | - |
testcase_06 | AC | 2 ms
5,504 KB |
testcase_07 | AC | 3 ms
5,424 KB |
testcase_08 | WA | - |
testcase_09 | AC | 4 ms
5,860 KB |
testcase_10 | AC | 5 ms
6,260 KB |
testcase_11 | AC | 20 ms
9,312 KB |
testcase_12 | AC | 50 ms
13,552 KB |
testcase_13 | AC | 68 ms
13,508 KB |
testcase_14 | AC | 60 ms
11,400 KB |
testcase_15 | AC | 3 ms
5,420 KB |
testcase_16 | AC | 3 ms
5,724 KB |
testcase_17 | AC | 4 ms
5,980 KB |
testcase_18 | AC | 7 ms
6,676 KB |
testcase_19 | AC | 64 ms
13,576 KB |
testcase_20 | AC | 66 ms
13,496 KB |
testcase_21 | AC | 70 ms
13,456 KB |
testcase_22 | AC | 68 ms
13,560 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, int]] 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).float64 b = abs(nodes[i][1] - y).float64 l : int if a < b: (a, b) = (b, a) if a == 0: r = 0 else: r = a * sqrt(1 + (b / a) * (b / a)) if r * r < b * b + a * a: r += 0.000001 r = r / 10 r = round(r + 0.00000001, 7).ceil l = r.int * 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], mincos[t.ID]): mincos[i] = max(hyou[i][t.ID], mincos[t.ID]) pq.push(( -mincos[i], i)) echo mincos[N - 1]