3622
правки
Изменения
→Реализация
<code>
'''int''' query ('''int''' node, '''int''' a, '''int''' b)
l = tree[node].left
r = tree[node].right
'''if''' [l, r) <tex>\cap </tex> [a, b) == <tex> \varnothing</tex>
'''return''''' neutral''
'''if''' [l, r) <tex>\subset</tex> [a, b)
'''return''' tree[node].res
'''return''' query (node * 2 + 1, a, b) <tex> \circ </tex> query (node * 2 + 2, a, b)
</code>