{"problem":{"name":"Abs Abs Function","description":{"content":"For a set $S$ of pairs of non-negative integers, and a non-negative integer $x$, let $f_S(x)$ defined as $\\displaystyle f_S(x)=\\min_{(a, b) \\in S} \\left| \\left| x-a \\right| - b \\right|$. We have a set","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc155_b"},"statements":[{"statement_type":"Markdown","content":"For a set $S$ of pairs of non-negative integers, and a non-negative integer $x$, let $f_S(x)$ defined as $\\displaystyle f_S(x)=\\min_{(a, b) \\in S} \\left| \\left| x-a \\right| - b \\right|$.\nWe have a set $T$ of pairs of non-negative integers. Initially, $T=\\lbrace (A, B)\\rbrace$.\nProcess $Q$ queries. The $i$\\-th query gives you three non-negative integers $t_i$, $a_i$, and $b_i$, and asks you to do the following.\n\n*   If $t_i=1$, add to $T$ the pair $(a_i, b_i)$ of non-negative integers.\n*   If $t_i=2$, print the minimum value of $f_{T}(x)$ for a non-negative integer $x$ such that $a_i \\leq x \\leq b_i$.\n\n## Constraints\n\n*   $1 \\leq Q \\leq 2 \\times 10^5$\n*   $0 \\leq A,B \\leq 10^{9}$\n*   $t_i$ is $1$ or $2$.\n*   $0 \\leq a_i,b_i \\leq 10^{9}$\n*   If $t_i=2$, then $a_i \\leq b_i$.\n*   There is at least one query with $t_i=2$.\n*   All values in the input are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$Q$ $A$ $B$\n$t_1$ $a_1$ $b_1$\n$t_2$ $a_2$ $b_2$\n$\\vdots$\n$t_Q$ $a_Q$ $b_Q$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc155_b","tags":[],"sample_group":[["4 0 5\n1 3 11\n2 7 8\n1 8 2\n2 8 9","2\n1\n\nIn the second query, $T=\\lbrace(0, 5), (3, 11) \\rbrace$. For $x=7$, we have $f_T(7)=\\min \\lbrace \\left| \\left|7-0\\right|-5\\right|, \\left| \\left|7-3\\right|-11\\right| \\rbrace=\\min \\lbrace 2, 7 \\rbrace=2$. Similarly, $f_T(8)=3$. Thus, the answer is $\\min \\lbrace 2, 3 \\rbrace =2$.\nIn the fourth query, $T=\\lbrace(0, 5), (3, 11), (8, 2) \\rbrace$. In $8 \\leq x \\leq 9$, $f_T(x)$ takes the minimum value $f_T(9)=1$ at $x=9$."],["2 1 2\n1 2 3\n2 2 6","0"],["20 795629912 123625148\n2 860243184 892786970\n2 645778367 668513124\n1 531411849 174630323\n1 635062977 195695960\n2 382061637 411843651\n1 585964296 589553566\n1 310118888 68936560\n1 525351160 858166280\n2 395304415 429823333\n2 583145399 703645715\n2 97768492 218377432\n1 707220749 459967102\n1 210842017 363390878\n2 489541834 553583525\n2 731279777 811513313\n1 549864943 493384741\n1 815378318 826084592\n2 369622093 374205455\n1 78240781 821999998\n2 241667193 243982581","26468090\n3491640\n25280111\n9543684\n0\n22804896\n20649370\n19245624\n4849993\n484865"]],"created_at":"2026-03-03 11:01:13"}}