結果

問題 No.2639 Longest Increasing Walk
ユーザー kemunikukemuniku
提出日時 2024-02-19 22:06:24
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 3,589 bytes
コンパイル時間 4,603 ms
コンパイル使用メモリ 77,224 KB
実行使用メモリ 27,064 KB
最終ジャッジ日時 2024-09-29 02:02:23
合計ジャッジ時間 7,427 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 1 ms
6,820 KB
testcase_03 AC 2 ms
6,820 KB
testcase_04 AC 96 ms
27,064 KB
testcase_05 AC 174 ms
26,696 KB
testcase_06 AC 180 ms
18,052 KB
testcase_07 AC 177 ms
18,136 KB
testcase_08 AC 186 ms
17,924 KB
testcase_09 AC 218 ms
26,740 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 16 ms
6,820 KB
testcase_13 WA -
testcase_14 AC 69 ms
9,344 KB
testcase_15 AC 1 ms
6,820 KB
testcase_16 WA -
testcase_17 AC 60 ms
9,600 KB
testcase_18 AC 85 ms
11,520 KB
testcase_19 WA -
testcase_20 AC 49 ms
7,936 KB
testcase_21 AC 103 ms
11,520 KB
testcase_22 WA -
testcase_23 AC 2 ms
6,816 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
6,820 KB
testcase_29 WA -
testcase_30 AC 2 ms
6,820 KB
testcase_31 AC 1 ms
6,820 KB
testcase_32 AC 1 ms
6,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import macros;macro ImportExpand(s:untyped):untyped = parseStmt($s[2])
ImportExpand "cplib/tmpl/sheep.nim" <=== "when not declared CPLIB_TMPL_SHEEP:\n    const CPLIB_TMPL_SHEEP* = 1\n    {.warning[UnusedImport]: off.}\n    {.hint[XDeclaredButNotUsed]: off.}\n    import algorithm\n    import sequtils\n    import tables\n    import macros\n    import math\n    import sets\n    import strutils\n    import strformat\n    import sugar\n    import heapqueue\n    import streams\n    import deques\n    import bitops\n    import std/lenientops\n    import options\n    #入力系\n    proc scanf(formatstr: cstring){.header: \"<stdio.h>\", varargs.}\n    proc getchar(): char {.importc: \"getchar_unlocked\", header: \"<stdio.h>\", discardable.}\n    proc ii(): int {.inline.} = scanf(\"%lld\\n\", addr result)\n    proc lii(N: int): seq[int] {.inline.} = newSeqWith(N, ii())\n    proc si(): string {.inline.} =\n        result = \"\"\n        var c: char\n        while true:\n            c = getchar()\n            if c == ' ' or c == '\\n':\n                break\n            result &= c\n    #chmin,chmax\n    template `max=`(x, y) = x = max(x, y)\n    template `min=`(x, y) = x = min(x, y)\n    #bit演算\n    proc `%`(x: int, y: int): int = (((x mod y)+y) mod y)\n    proc `//`(x: int, y: int): int = (((x) - (x%y)) div (y))\n    proc `%=`(x: var int, y: int): void = x = x%y\n    proc `//=`(x: var int, y: int): void = x = x//y\n    proc `**`(x: int, y: int): int = x^y\n    proc `^`(x: int, y: int): int = x xor y\n    proc `|`(x: int, y: int): int = x or y\n    proc `&`(x: int, y: int): int = x and y\n    proc `>>`(x: int, y: int): int = x shr y\n    proc `<<`(x: int, y: int): int = x shl y\n    proc `^=`(x: var int, y: int): void = x = x ^ y\n    proc `&=`(x: var int, y: int): void = x = x & y\n    proc `|=`(x: var int, y: int): void = x = x | y\n    proc `>>=`(x: var int, y: int): void = x = x >> y\n    proc `<<=`(x: var int, y: int): void = x = x << y\n    proc `[]`(x: int, n: int): bool = (x and (1 shl n)) != 0\n    proc `@`(x: int): seq[int] =\n        for i in 0..<64:\n            if x[i]:\n                result.add(i)\n    #便利な変換\n    proc `!`(x: char, a = '0'): int = int(x)-int(a)\n    #定数\n    const INF = int(3300300300300300491)\n    #converter\n\n    #range\n    iterator range(start: int, ends: int, step: int): int =\n        var i = start\n        if step < 0:\n            while i > ends:\n                yield i\n                i += step\n        elif step > 0:\n            while i < ends:\n                yield i\n                i += step\n    iterator range(ends: int): int = (for i in 0..<ends: yield i)\n    iterator range(start: int, ends: int): int = (for i in\n            start..<ends: yield i)\n"
var H,W = ii()
var A = newSeqWith(H,newSeqWith(W,ii()))
var x : seq[(int,int,int)]
for i in range(H):
    for j in range(W):
        x.add((A[i][j],i,j))
var alr = newSeqWith(H,newSeqWith(W,-1))
x.sort()
for (a,i,j) in x:
    if alr[i][j] == -1:
        var hq = initHeapQueue[(int,int,int,int)]()
        hq.push((a,i,j,-1))
        while len(hq) != 0:
            var (a,i,j,c) = hq.pop()
            if alr[i][j] != -1:
                continue
            c = -c
            alr[i][j] = c
            for (di,dj) in [(0,1),(1,0),(-1,0),(0,-1)]:
                if i+di in 0..<H and j+dj in 0..<W:
                    if a < A[i+di][j+dj] and alr[i+di][j+dj] == -1:
                        hq.push((A[i+di][j+dj],i+di,j+dj,-(c+1)))
    # for i in range(H):
    #     echo(alr[i])
    # echo ""

echo alr.mapit(max(it)).max
0