| 102 | } |
| 103 | |
| 104 | public static void main(String[] args) throws Exception { |
| 105 | FastReader in = new FastReader(System.in); |
| 106 | PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); |
| 107 | n = in.nextInt(); |
| 108 | m = in.nextInt(); |
| 109 | prepare(); |
| 110 | for (int i = 1; i <= n; i++) { |
| 111 | num[i] = in.nextInt(); |
| 112 | } |
| 113 | for (int i = 1, op, x, y, z; i <= m; i++) { |
| 114 | op = in.nextInt(); |
| 115 | if (op == 0) { |
| 116 | x = in.nextInt(); |
| 117 | y = in.nextInt(); |
| 118 | // 删除后需要更新集合x的堆头 |
| 119 | root[x] = remove(y); |
| 120 | if (root[x] != 0) { |
| 121 | father[root[x]] = root[x]; |
| 122 | up[root[x]] = 0; |
| 123 | } |
| 124 | } else if (op == 1) { |
| 125 | x = in.nextInt(); |
| 126 | out.println(num[root[x]]); |
| 127 | } else if (op == 2) { |
| 128 | x = in.nextInt(); |
| 129 | y = in.nextInt(); |
| 130 | // 合并集合x和集合y |
| 131 | root[x] = merge(root[x], root[y]); |
| 132 | if (root[x] != 0) { |
| 133 | father[root[x]] = root[x]; |
| 134 | up[root[x]] = 0; |
| 135 | } |
| 136 | } else { |
| 137 | x = in.nextInt(); |
| 138 | y = in.nextInt(); |
| 139 | z = in.nextInt(); |
| 140 | int h = remove(y); |
| 141 | num[y] = z; |
| 142 | // y改值后重新作为单点堆 |
| 143 | father[y] = y; |
| 144 | // 合并到集合x |
| 145 | root[x] = merge(h, y); |
| 146 | if (root[x] != 0) { |
| 147 | father[root[x]] = root[x]; |
| 148 | up[root[x]] = 0; |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | out.flush(); |
| 153 | out.close(); |
| 154 | } |
| 155 | |
| 156 | // 读写工具类 |
| 157 | static class FastReader { |