python3 (by cursor)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nfrom sortedcontainers import SortedList\n\nclass SegmentTree:\n    """\n    \u4F18\u5316\u7248\u7EBF\u6BB5\u6811\u5B9E\u73B0\uFF0C\u4F7F\u7528SortedList\u7EF4\u62A4\u6709\u5E8Flocation\n    \u6240\u6709\u64CD\u4F5C\u7684\u65F6\u95F4\u590D\u6742\u5EA6\u5747\u4E3AO(log n)\n    """\n    def __init__(self, max_size=100000):\n        self.locations = SortedList([0])  # \u521D\u59CB\u5316\u5305\u542Blocation=0\n        self.max_tree = [0] * (4 * max_size)  # \u9884\u5206\u914D\u7EBF\u6BB5\u6811\u7A7A\u95F4\n        self.max_size = max_size\n        \n        # \u521D\u59CB\u5316location=0\u7684distance\u4E3A-1\n        self._update(0, 0, self.max_size-1, 0, -1)\n        \n    def add(self, location: int) -> None:\n        """\n        \u6DFB\u52A0\u4E00\u4E2Alocation\n        \u65F6\u95F4\u590D\u6742\u5EA6: O(log n)\n        """\n        if location in self.locations or location >= self.max_size:\n            return\n            \n        # \u8BA1\u7B97\u65B0location\u7684distance\n        idx = self.locations.bisect_left(location)\n        distance = location - self.locations[idx-1]  # \u4E00\u5B9A\u5B58\u5728\u524D\u9A71(\u81F3\u5C11\u67090)\n        \n        # \u6DFB\u52A0\u65B0location\u5E76\u66F4\u65B0\u7EBF\u6BB5\u6811\n        self.locations.add(location)\n        self._update(0, 0, self.max_size-1, location, distance)\n        \n        # \u66F4\u65B0\u53D7\u5F71\u54CD\u7684\u540E\u7EEDlocation\u7684distance\n        next_idx = self.locations.bisect_right(location)\n        if next_idx < len(self.locations):\n            next_loc = self.locations[next_idx]\n            next_distance = next_loc - location\n            self._update(0, 0, self.max_size-1, next_loc, next_distance)\n        \n    def modify(self, old_location: int, new_location: int) -> None:\n        """\n        \u4FEE\u6539location\u503C\n        \u65F6\u95F4\u590D\u6742\u5EA6: O(log n)\n        \u4E0D\u5141\u8BB8\u4FEE\u6539location=0\n        """\n        if old_location == 0 or old_location not in self.locations:\n            return\n            \n        self.remove(old_location)\n        self.add(new_location)\n        \n    def remove(self, location: int) -> None:\n        """\n        \u79FB\u9664\u6307\u5B9Alocation\n        \u65F6\u95F4\u590D\u6742\u5EA6: O(log n)\n        \u4E0D\u5141\u8BB8\u79FB\u9664location=0\n        """\n        if location == 0 or location not in self.locations:\n            return\n            \n        # \u79FB\u9664location\n        idx = self.locations.bisect_left(location)\n        self.locations.remove(location)\n        \n        # \u66F4\u65B0\u53D7\u5F71\u54CD\u7684\u540E\u7EEDlocation\u7684distance\n        if idx < len(self.locations):\n            next_loc = self.locations[idx]\n            prev_loc = self.locations[idx-1]\n            distance = next_loc - prev_loc\n            self._update(0, 0, self.max_size-1, next_loc, distance)\n            \n    def query(self, x: int) -> tuple[int, int, int]:\n        """\n        \u5BF9\u4E8E\u7ED9\u5B9A\u7684x\uFF0C\u8FD4\u56DE:\n        1. \u5C0F\u4E8E\u7B49\u4E8Ex\u7684\u6700\u5927location\n        2. \u5927\u4E8Ex\u7684\u6700\u5C0Flocation\n        3. \u6240\u6709\u5C0F\u4E8Ex\u7684location\u4E4B\u95F4\u7684\u6700\u5927distance\n        \u65F6\u95F4\u590D\u6742\u5EA6: O(log n)\n        """\n        # \u627E\u5230\u5C0F\u4E8E\u7B49\u4E8Ex\u7684\u6700\u5927location\n        idx = self.locations.bisect_right(x)\n        max_le = self.locations[idx-1]  # \u4E00\u5B9A\u5B58\u5728(\u81F3\u5C11\u67090)\n        \n        # \u627E\u5230\u5927\u4E8Ex\u7684\u6700\u5C0Flocation\n        min_gt = self.locations[idx] if idx < len(self.locations) else -1\n        \n        # \u67E5\u8BE2\u6700\u5927distance\n        max_dist = self._query(0, 0, self.max_size-1, 1, x)  # \u4ECE1\u5F00\u59CB\u67E5\u8BE2\uFF0C\u8DF3\u8FC7location=0\n        if max_dist == 0:  # \u5982\u679C\u6CA1\u6709\u5176\u4ED6location\uFF0Cdistance\u5C31\u662Fx-0\n            max_dist = x\n        \n        return (max_le, min_gt, max_dist)\n        \n    def _update(self, node: int, start: int, end: int, loc: int, val: int) -> None:\n        """\n        \u66F4\u65B0\u7EBF\u6BB5\u6811\u7684\u8F85\u52A9\u51FD\u6570\n        \u4F7F\u7528location\u503C\u800C\u4E0D\u662F\u7D22\u5F15\u6765\u66F4\u65B0\n        """\n        if start == end:\n            self.max_tree[node] = val\n            return\n            \n        mid = (start + end) // 2\n        left = 2 * node + 1\n        right = 2 * node + 2\n        \n        if loc <= mid:\n            self._update(left, start, mid, loc, val)\n        else:\n            self._update(right, mid+1, end, loc, val)\n            \n        self.max_tree[node] = max(self.max_tree[left], self.max_tree[right])\n        \n    def _query(self, node: int, start: int, end: int, l: int, r: int) -> int:\n        """\n        \u67E5\u8BE2\u533A\u95F4\u6700\u5927\u503C\u7684\u8F85\u52A9\u51FD\u6570\n        \u4F7F\u7528location\u503C\u800C\u4E0D\u662F\u7D22\u5F15\u6765\u67E5\u8BE2\n        """\n        if r < start or l > end or l > r:\n            return 0\n            \n        if l <= start and end <= r:\n            return self.max_tree[node]\n            \n        mid = (start + end) // 2\n        left = 2 * node + 1\n        right = 2 * node + 2\n        \n        left_max = self._query(left, start, mid, l, r)\n        right_max = self._query(right, mid+1, end, l, r)\n        return max(left_max, right_max)\n\n\n\nclass Solution:\n    def getResults(self, queries: List[List[int]]) -> List[bool]:\n        stree = SegmentTree()\n        results = []\n        for query in queries:\n            if query[0] == 1:\n                stree.add(query[1])\n                # print(stree.locations, stree.max_tree)\n                # print(stree.locations)\n\n                # for i in range(0, 20):\n                #     l, r, max_dst = stree.query(i)\n                #     print("query(", i, ") ", l, r, max_dst)\n            else:\n                l, r, max_dst = stree.query(query[1])\n                # print("query(", query[1], ") ", l, r, max_dst)\n                results.append( max(max_dst, query[1]-l) >= query[2])\n        \n        return results\n        \n```
['Python3']