Untitled
Never
class SegNode { public: int left, right, mid; SegNode *lc = nullptr, *rc = nullptr; bool modified = false; bool covered = false; bool empty = true; SegNode(int left, int right){ this->left=left; this->right=right; this->mid=left+(right-left)/2; } void addRange(int left, int right){ if (left<=this->left&&right>=this->right){ if (!covered) { covered = true; modified=true; empty=false; } } else { pushdown(); if (left<=mid) this->lc->addRange(left, right); if (right>mid)this->rc->addRange(left, right); maintain(); } } void maintain(){ this->covered=this->lc->covered&&this->rc->covered; this->empty=this->lc->empty&&this->rc->empty; } void removeRange(int left, int right){ if (left<=this->left&&right>=this->right){ if (!empty){ empty=true; covered=false; modified=true; } } else { pushdown(); if (left<=mid)this->lc->removeRange(left, right); if (right>mid)this->rc->removeRange(left, right); maintain(); } } bool query(int left, int right){ if (this->empty)return false; if (this->covered)return true; if (left<=this->left&&right>=this->right) { return this->covered; } bool ans=true; if (left<=mid)ans&=this->lc->query(left, right); if (right>mid)ans&=this->rc->query(left, right); return ans; } void pushdown(){ if (this->lc==nullptr){ this->lc=new SegNode(left, mid); this->lc->covered=this->covered; this->lc->empty=this->empty; this->rc=new SegNode(mid+1,right); this->rc->covered=this->covered; this->rc->empty=this->empty; this->modified=false; } else if (modified){ this->lc->covered=this->covered; this->lc->empty=this->empty; this->lc->modified=true; this->rc->covered=this->covered; this->rc->empty=this->empty; this->rc->modified=true; this->modified=false; } } }; class RangeModule { public: SegNode *root; RangeModule() { root = new SegNode(1, 1000000000); } void addRange(int left, int right) { root->addRange(left, right-1); } bool queryRange(int left, int right) { return root->query(left, right-1); } void removeRange(int left, int right) { root->removeRange(left, right-1); } };
Raw Text
-
Trashy romance
1 min ago
-
Quick Books Customer service
1 min ago
-
The Hairiest Pussy's you've ever seen!
11 min ago
-
V BUCKS GENERATOR
18 min ago
-
Furiosa: A Mad Max Saga Streamcloud Deutsch Ganzer Film
28 min ago
-
She SWALLOWED cum for MONEY!
40 min ago
-
https://twor.microsoftcrmportals.com/forums/support-forum/faf992e5-2002-ef11-a73d-6045bd3fd1cb
45 min ago
-
https://twor.microsoftcrmportals.com/forums/support-forum/faf992e5-2002-ef11-a73d-6045bd3fd1cb
46 min ago
-
bnbwt
47 min ago
-
Punk'd Parody - MYLF
1 hour ago