---
id: 530
lang: en
translation_of: index.md
source_sha256: 5d3c06ece83208bb716cf813dab0d196ecd8912408deccc176f2d4ee4de36655
title: "[SDOI2016] Game — Solution"
description: "Heavy-light decomposition plus lazy tags that store lines, pushing the lower edge of the lines down to the children."
tags: ["OI","Segment Tree","Li Chao Tree","Heavy-Light Decomposition"]
translated: 2026-11-27
translator: Claude Opus 5.5
translator_model: claude-opus-5-5
translation_notes:
  - "直线下边缘 rendered literally as “the lower edge of the lines”."
---

## Approach

Clearly we need heavy-light decomposition.

For each operation of the form $a \times dis + b$, add it to the lazy tag. If we run into lazy information that is already there, we only need to think of such an operation as adding a line, and push the lower edge of the lines down to the left and right children. (Compute the lengths to decide whether to push down left or right.) For each node, the lazy addition is the sum of an arithmetic sequence: compute $b \times subtreeSize + a \times \frac{subtreeSize*(subtreeSize-1)}{2}$.
