結果
問題 | No.124 門松列(3) |
ユーザー |
![]() |
提出日時 | 2017-09-03 20:40:11 |
言語 | Nim (2.2.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,751 bytes |
コンパイル時間 | 684 ms |
コンパイル使用メモリ | 64,688 KB |
最終ジャッジ日時 | 2024-06-30 03:07:28 |
合計ジャッジ時間 | 1,158 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
/home/judge/data/code/Main.nim(25, 25) Warning: Number of spaces around '<=' is not consistent [Spacing] /home/judge/data/code/Main.nim(52, 30) Error: type mismatch: got 'seq[int]' for 'map(split(readLine(stdin), {' ', '\t', '\v', '\r', '\n', '\f'}, -1), parseInt)' but expected 'tuple'
ソースコード
import sequtils,strutils,mathimport sequtils,strutilstypepriorityQue[I:static[int];T:tuple] = array[I + 1,T]item = tuple[cost, x, y, a : int]proc push[T](A:var priorityQue; b: T;)=const key = 0A[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 = 0result = A[1]A[1] = A[A[0][0]]var n : itemA[A[0][0]] = nA[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]varW, H : inthyou : array[103, array[103, int]]pq : priorityQue[10000000, item]p : itemD = [[1, 0],[0, 1],[-1, 0],[0, -1]]flag : array[103, array[103, array[4, bool]]](W, H) = stdin.readline.split.map(parseInt)for h in 1..H:hyou[h][1..W] = stdin.readline.split.map(parseInt)proc isKadomatsuSequence(a, b, c : int) : bool =if b == 0 or a == 0:return trueif a != b and b != c and c != a:if b == max(@[a, b, c]):return trueelif b == min(@[a, b, c]):return trueelse:return falseelse:return falsep = (0, 1, 1, 0)pq.push(p)block tansaku:while pq.size > 0:p = pq.pop()if p.cost < - 10000:breakfor j,d in D:varnx = p.x + d[1]ny = p.y + d[0]if hyou[ny][nx] == 0:continuevarb = hyou[p.y][p.x]a = p.ac = hyou[ny][nx]if isKadomatsuSequence(a, b, c):if flag[ny][nx][j] == true:continueflag[ny][nx][j] = trueif nx == W and ny == H:echo -p.cost + 1break tansakupq.push((p.cost - 1, nx, ny, b))echo -1