Skip to content

Commit ea8a09a

Browse files
Toshihiro ShimizuToshihiro Shimizu
Toshihiro Shimizu
authored and
Toshihiro Shimizu
committed
splay treeを修正
1 parent 57b38af commit ea8a09a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/atcoder/extra/structure/splay_tree.nim

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,18 @@ when not declared ATCODER_SPLAY_TREE_HPP:
210210
211211
proc get_left*[T:SomeSplayTree](self:T, t:T.Node):T.Node =
212212
var t = t
213-
while t.l != self.leaf: t = t.l
213+
while true:
214+
self.push(t)
215+
if t.l == self.leaf: break
216+
t = t.l
214217
return t
215218
216219
proc get_right*[T:SomeSplayTree](self:T, t:T.Node):T.Node =
217220
var t = t
218-
while t.r != self.leaf: t = t.r
221+
while true:
222+
self.push(t)
223+
if t.r == self.leaf: break
224+
t = t.r
219225
return t
220226
221227
proc erase*[T:SomeSplayTree](self:T, root:var T.Node, t:T.Node, return_right:static[bool] = true):T.Node =

0 commit comments

Comments
 (0)