正文
增加 6 行删除 6 行
23 行未改动2425262728293031323334353637262 行未改动全部展开3003013023033043053063073085 行未改动31431531631731831932032132281 行未改动40440540640740840941041141212 行未改动4254264274284294304314324337 行未改动23 行未改动Node* ch[2]; // 左右儿子int val, prio; // 值、优先级int cnt; // 重复值计数int siz; // 子树大小Node(int _val) : val(_val), cnt(1), siz(1) {ch[0] = ch[1] = nullptr;prio = rnd();} // 初始化void upd_siz() {siz = cnt;if (ch[0] != nullptr) siz += ch[0]->siz;if (ch[1] != nullptr) siz += ch[1]->siz;262 行未改动全部展开rmax = max(max(ch[1]->rmax, ch[1]->sum + val + ch[0]->rmax), 0ll);maxn = max(max(max(ch[0]->rmax + ch[1]->lmax, 0ll) + val, ch[0]->maxn), ch[1]->maxn);}}inline void cover(int c) {val = c;sum = c * siz;lmax = rmax = max(sum, 0ll);5 行未改动swap(ch[0], ch[1]);swap(lmax, rmax);to_rev ^= 1;}inline void pushdown() {if (to_same) {if (ch[0] != nullptr) ch[0]->cover(val);if (ch[1] != nullptr) ch[1]->cover(val);81 行未改动auto tmp2 = split(tmp.second, len);if (tmp2.first != nullptr) tmp2.first->cover(c);root = merge(merge(tmp.first, tmp2.first), tmp2.second);}inline void reverse(int pos, int len) {auto tmp = split(root, pos - 1);auto tmp2 = split(tmp.second, len);if (tmp2.first != nullptr) tmp2.first->rev();12 行未改动int ret = (tmp2.first == nullptr ? 0 : tmp2.first->sum);root = merge(merge(tmp.first, tmp2.first), tmp2.second);return ret;}inline int max_sum() {if (root != nullptr) return root->maxn;return 0;}7 行未改动23 行未改动2425262728293031323334353637262 行未改动全部展开3003013023033043053063073085 行未改动31431531631731831932032132281 行未改动40440540640740840941041141212 行未改动4254264274284294304314324337 行未改动23 行未改动Node* ch[2]; // 左右儿子int val, prio; // 值、优先级int cnt; // 重复值计数int siz; // 子树大小Node(int _val) : val(_val), cnt(1), siz(1) {ch[0] = ch[1] = nullptr;prio = rnd();} // 初始化void upd_siz() {siz = cnt;if (ch[0] != nullptr) siz += ch[0]->siz;if (ch[1] != nullptr) siz += ch[1]->siz;262 行未改动全部展开rmax = max(max(ch[1]->rmax, ch[1]->sum + val + ch[0]->rmax), 0ll);maxn = max(max(max(ch[0]->rmax + ch[1]->lmax, 0ll) + val, ch[0]->maxn), ch[1]->maxn);}}inline void cover(int c) {val = c;sum = c * siz;lmax = rmax = max(sum, 0ll);5 行未改动swap(ch[0], ch[1]);swap(lmax, rmax);to_rev ^= 1;}inline void pushdown() {if (to_same) {if (ch[0] != nullptr) ch[0]->cover(val);if (ch[1] != nullptr) ch[1]->cover(val);81 行未改动auto tmp2 = split(tmp.second, len);if (tmp2.first != nullptr) tmp2.first->cover(c);root = merge(merge(tmp.first, tmp2.first), tmp2.second);}inline void reverse(int pos, int len) {auto tmp = split(root, pos - 1);auto tmp2 = split(tmp.second, len);if (tmp2.first != nullptr) tmp2.first->rev();12 行未改动int ret = (tmp2.first == nullptr ? 0 : tmp2.first->sum);root = merge(merge(tmp.first, tmp2.first), tmp2.second);return ret;}inline int max_sum() {if (root != nullptr) return root->maxn;return 0;}7 行未改动