P2757 [国家集训队] 等差子序列
在线段树存哈希的时候,注意字符长度的改变,否则 query 会崩掉
lol query (int u, int l, int r, int lft, int rht)
{
if (lft <= l && r <= rht)
return tr[u];
else
{
int mid = (l + r) >> 1;
if (rht <= mid) return query(u << 1, l, mid, lft, rht);
if (mid < lft) return query(u << 1 | 1, mid + 1, r, lft, rht);
lol lt = query(u << 1, l, mid, lft, rht), rt = query(u << 1 | 1, mid + 1, r, lft, rht), res;
push_up (res, lt, rt, min (rht, r) - mid);
return res;
}
}
其中 min (rht, r) - mid
如果写成 rht - mid
或者 r - mid
就挂掉了