結果
問題 | No.971 いたずらっ子 |
ユーザー | chaemon |
提出日時 | 2020-01-17 21:38:01 |
言語 | Nim (2.0.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,540 bytes |
コンパイル時間 | 4,010 ms |
コンパイル使用メモリ | 72,752 KB |
実行使用メモリ | 77,600 KB |
最終ジャッジ日時 | 2024-06-25 19:00:49 |
合計ジャッジ時間 | 13,929 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 966 ms
75,264 KB |
testcase_04 | AC | 907 ms
71,552 KB |
testcase_05 | AC | 968 ms
75,264 KB |
testcase_06 | AC | 741 ms
66,688 KB |
testcase_07 | WA | - |
testcase_08 | AC | 240 ms
29,052 KB |
testcase_09 | AC | 223 ms
20,352 KB |
testcase_10 | AC | 7 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | WA | - |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
コンパイルメッセージ
/home/judge/data/code/Main.nim(2, 57) Warning: imported and not used: 'strutils' [UnusedImport] /home/judge/data/code/Main.nim(2, 45) Warning: imported and not used: 'math' [UnusedImport] /home/judge/data/code/Main.nim(2, 29) Warning: imported and not used: 'tables' [UnusedImport] /home/judge/data/code/Main.nim(2, 37) Warning: imported and not used: 'macros' [UnusedImport]
ソースコード
#{{{ header import algorithm, sequtils, tables, macros, math, sets, strutils when defined(MYDEBUG): import header proc scanf(formatstr: cstring){.header: "<stdio.h>", varargs.} proc getchar(): char {.header: "<stdio.h>", varargs.} proc nextInt(): int = scanf("%lld",addr result) proc nextFloat(): float = scanf("%lf",addr result) proc nextString(): string = var get = false result = "" while true: var c = getchar() if int(c) > int(' '): get = true result.add(c) else: if get: break get = false template `max=`*(x,y:typed):void = x = max(x,y) template `min=`*(x,y:typed):void = x = min(x,y) template inf(T): untyped = ((T(1) shl T(sizeof(T)*8-2)) - 1) #}}} import heapqueue proc main():void = let H, W = nextInt() let a = newSeqWith(H, nextString()) var g = newSeqWith(H, newSeqWith(W, 0)) for i in 0..<H: for j in 0..<W: if a[i][j] == 'k': g[i][j] = i + j else: g[i][j] = 0 var dist = newSeqWith(H, newSeqWith(W, int.inf)) proc inner(x, y:int):bool = (0 <= x and x < H and 0 <= y and y < W) let vx = [0,1, 0,-1] vy = [1,0,-1, 0] var q = initHeapQueue[(int,(int,int))]() dist[0][0] = 0 q.push((0,(0,0))) while q.len > 0: let t = q.pop() let (x, y) = t[1] for i in 0..<4: let (x2, y2) = (x + vx[i], y + vy[i]) if not inner(x2, y2): continue let d2 = dist[x][y] + g[x2][y2] + 1 if d2 < dist[x2][y2]: dist[x2][y2] = d2 q.push((d2, (x2, y2))) echo dist[H-1][W-1] discard main()