00-区间-02-线段树分块.svg 1.9 KB

1234567
  1. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 840 310" role="img" aria-labelledby="title desc">
  2. <title id="title">线段树的区间分治摘要</title><desc id="desc">根代表一到八,子节点代表更小区间,查询二到七可由少数节点合并。</desc>
  3. <style>text{font-family:system-ui,sans-serif;fill:#172033}.line{stroke:#94a3b8;stroke-width:3}.node{fill:#eff6ff;stroke:#2563eb;stroke-width:3}.hit{fill:#dcfce7;stroke:#16a34a;stroke-width:4}.note{font-size:18px}.label{font-size:18px;font-weight:700}</style>
  4. <text x="25" y="28" class="note">每个节点保管一个区间摘要;查询只拿完全落入目标的节点。</text>
  5. <line class="line" x1="420" y1="70" x2="240" y2="130"/><line class="line" x1="420" y1="70" x2="600" y2="130"/><line class="line" x1="240" y1="160" x2="140" y2="220"/><line class="line" x1="240" y1="160" x2="340" y2="220"/><line class="line" x1="600" y1="160" x2="500" y2="220"/><line class="line" x1="600" y1="160" x2="700" y2="220"/>
  6. <rect class="node" x="375" y="42" width="90" height="36" rx="8"/><text class="label" x="394" y="66">[1,8]</text><rect class="node" x="195" y="122" width="90" height="36" rx="8"/><text class="label" x="214" y="146">[1,4]</text><rect class="node" x="555" y="122" width="90" height="36" rx="8"/><text class="label" x="574" y="146">[5,8]</text><rect class="hit" x="95" y="212" width="90" height="36" rx="8"/><text class="label" x="114" y="236">[1,2]</text><rect class="hit" x="295" y="212" width="90" height="36" rx="8"/><text class="label" x="314" y="236">[3,4]</text><rect class="hit" x="455" y="212" width="90" height="36" rx="8"/><text class="label" x="474" y="236">[5,6]</text><rect class="hit" x="655" y="212" width="90" height="36" rx="8"/><text class="label" x="674" y="236">[7,8]</text><text x="235" y="290" class="note">例如查询 [2,7] 时,绿色节点的边界还会继续细分;不相交部分不访问。</text>
  7. </svg>