{"problem":{"name":"[ROI 2017] 排序幻觉 (Day 1)","description":{"content":"给定长度为 $n$ 的整数数列 $a$，如果一个整数 $b$ 满足： $$ (a_1 \\operatorname{xor} b) \\le (a_2 \\operatorname{xor} b) \\le \\dots \\le (a_n \\operatorname{xor} b) $$ 则称 $b$ 是 $a$ 数列的**幻数**。 接下来有 $q$ 次修改，每次修改一个数 $a_{u_i}$ 为整","description_type":"Markdown"},"platform":"Luogu","limit":{"time_limit":2000,"memory_limit":524288},"difficulty":{"LuoguStyle":"P4"},"is_remote":true,"is_sync":true,"sync_url":null,"sign":"LGP10650"},"statements":[{"statement_type":"Markdown","content":"给定长度为 $n$ 的整数数列 $a$，如果一个整数 $b$ 满足：\n\n$$\n(a_1 \\operatorname{xor} b) \\le (a_2 \\operatorname{xor} b) \\le \\dots \\le (a_n \\operatorname{xor} b)\n$$\n\n则称 $b$ 是 $a$ 数列的**幻数**。\n\n接下来有 $q$ 次修改，每次修改一个数 $a_{u_i}$ 为整数 $k_i$，每次修改都会对后面的询问产生影响。你需要求出第一次修改前以及每次修改后这个数列的最小的幻数是多少，特别的，如果不存在幻数请输出 $-1$。\n\n## Input\n\n第一行一个整数 $n$ 表示数列长度。\n\n第二行 $n$ 个整数表示整数数列 $a$。\n\n第三行一个整数 $q$ 表示询问次数。\n\n接下来 $q$ 行每行两个整数 $u_i,k_i$，表示将 $a_{u_i}$ 修改为 $k_i$。\n\n## Output\n\n共 $(q+1)$ 行，每行一个整数表示当前数列最小的幻数，如果没有幻数请输出 $-1$。\n\n[samples]\n\n## Note\n\n#### 【数据范围】\n\n| 子任务编号 | 分值 | $1 \\le n \\le$ | $1 \\le q \\le $ | $0 \\le a_i,k_i \\le$ |\n| :----------: | :----------: | :----------: | :----------: | :----------: |\n| $1$ | $30$ | $500$ | $500$ | $2^9$ |\n| $2$ | $29$ | $10^3$ | $10^3$ | $2^{30}$ |\n| $3$ | $21$ | $10^5$ | $10^5$ | $2^{30}$ |\n| $4$ | $30$ | $10^6$ | $10^6$ | $2^{30}$ |","is_translate":false,"language":"English"}],"meta":{"iden":"LGP10650","tags":["贪心","2017","O2优化","位运算","ROI（俄罗斯）"],"sample_group":[["3\n0 1 4\n3\n2 7\n3 3\n1 4","0\n2\n-1\n4"]],"created_at":"2026-03-03 11:09:25"}}