| 1234567 |
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 840 280" role="img" aria-labelledby="title desc">
- <title id="title">Fenwick 树节点覆盖区间</title><desc id="desc">tree 四覆盖一到四,tree 六覆盖五到六,前缀六可以由两个块相加。</desc>
- <style>text{font-family:system-ui,sans-serif;fill:#172033}.cell{fill:#f8fafc;stroke:#64748b;stroke-width:2}.block1{fill:#bfdbfe;stroke:#2563eb;stroke-width:3}.block2{fill:#fed7aa;stroke:#ea580c;stroke-width:3}.note{font-size:18px}.label{font-size:20px;font-weight:700}</style>
- <text x="26" y="30" class="note">prefix(6) 不是逐个加 1..6:tree[6] 管 [5,6],tree[4] 管 [1,4]。</text>
- <g transform="translate(90 105)"><rect class="block1" x="0" y="0" width="80" height="55"/><rect class="block1" x="80" y="0" width="80" height="55"/><rect class="block1" x="160" y="0" width="80" height="55"/><rect class="block1" x="240" y="0" width="80" height="55"/><rect class="block2" x="320" y="0" width="80" height="55"/><rect class="block2" x="400" y="0" width="80" height="55"/><rect class="cell" x="480" y="0" width="80" height="55"/><rect class="cell" x="560" y="0" width="80" height="55"/><text class="label" x="34" y="35">1</text><text class="label" x="114" y="35">2</text><text class="label" x="194" y="35">3</text><text class="label" x="274" y="35">4</text><text class="label" x="354" y="35">5</text><text class="label" x="434" y="35">6</text><text class="label" x="514" y="35">7</text><text class="label" x="594" y="35">8</text></g>
- <path d="M250 95 L250 64" stroke="#2563eb" stroke-width="4"/><text x="170" y="56" class="note" fill="#1d4ed8">tree[4] = [1,4]</text><path d="M530 95 L530 64" stroke="#ea580c" stroke-width="4"/><text x="450" y="56" class="note" fill="#c2410c">tree[6] = [5,6]</text><text x="191" y="234" class="note">lowbit(6)=2,6 → 4 → 0:每一步拿走一个不重叠尾块。</text>
- </svg>
|