verify/AI/compressed_trie_test.nim

This documentation is automatically generated by online-judge-tools/verification-helper

:heavy_check_mark: verify/AI/compressed_trie_test.nim

Depends on

Code

# verification-helper: PROBLEM https://onlinejudge.u-aizu.ac.jp/problems/ITP1_1_A
echo "Hello World"

import algorithm, sequtils
import cplib/graph/graph
import cplib/str/compressed_trie
import cplib/str/static_string

let emptyRoot = initCompressedTrie(newSeq[StaticString[char]]())
assert emptyRoot.get_virtualnode.get_cnt == 0
assert emptyRoot.get_virtualnode.get_subtree_sum == 0
assert emptyRoot.toGraph.len == 1

let words = toStaticStrings(@["a", "ab", "ab", "ac", "b"])
let root = initCompressedTrie(words)
let vr = root.get_virtualnode
assert vr.get_cnt == 0
assert vr.get_subtree_sum == 5
assert vr.has_child('a')
assert vr.has_child('b')

let va = vr.get_child('a')
assert va.get_cnt == 1
assert va.get_subtree_sum == 4
assert va.has_child('b')
assert va.has_child('c')
assert va.get_child('b').get_cnt == 2
assert va.get_child('c').get_cnt == 1
assert vr.get_child('b').get_cnt == 1

let g = root.toGraph()
assert g.len >= 3
assert toSeq(g[0]).mapIt($it[1]).sorted == @["a", "b"]
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.12/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.local/lib/python3.12/site-packages/onlinejudge_verify/languages/nim.py", line 86, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page