+ "code": "int const N = 5 * 1e4 + 10;\nint seg[4 * N];\n\n\n\nclass Solution {\npublic:\n void update(int ind, int ss, int se, int idx, int val){\n if(ss == se){\n seg[ind] = val;\n return;\n }\n int mid = (ss + se)/2;\n if(idx <= mid){\n update(2 * ind + 1, ss, mid, idx, val);\n }else{\n update(2 * ind + 2, mid + 1, se, idx, val);\n }\n seg[ind] = max(seg[2 * ind + 1], seg[2 * ind + 2]);\n }\n\n int query(int ind, int ss ,int se, int qs, int qe){\n if(se < qs || ss > qe){\n return 0;\n }\n if(ss >= qs && se <= qe){\n return seg[ind];\n }\n int mid = (ss + se)/2;\n int l = query(2 * ind + 1, ss, mid, qs, qe);\n int r = query(2 * ind + 2, mid + 1, se, qs, qe);\n return max(l, r);\n }\n vector<bool> getResults(vector<vector<int>>& queries) {\n memset(seg, 0, sizeof seg);\n set<int> st;\n st.insert(0);\n st.insert(N - 1);\n \n //\n update(0, 0, N - 1, N - 1, (N - 1) - 0);\n //\n vector<bool> ans;\n for (const auto& i : queries) {\n if (i[0] == 1) {\n int x = i[1];\n auto it = st.upper_bound(x);\n update(0, 0, N - 1, *it, *it - x);\n it--;\n update(0, 0, N - 1, x, x - *it);\n st.insert(x);\n } else {\n int x = i[1];\n int sz = i[2];\n int t = query(0, 0, N - 1, 0, x);\n auto it = st.lower_bound(x);\n it--;\n bool f = false;\n if(t >= sz || x - *it >= sz){\n f = true;\n }\n ans.push_back(f);\n }\n }\n return ans;\n }\n};"
0 commit comments