Pro.ID22041 TitleAtomic Nucleus Investigation Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22041 AC7 Submit31 Ratio22.58% 时间&空间限制描述Recently the physicists have been investigating a large family of atomic nucleuses, named "X family". They have discovered that these atomic nucleuses in X family are quite similar to each other, and can only be distinguished by their weights. And the smaller the weight difference between two kinds of nucleuses is, the more possibly one kind tend to transform to the other.To research X family in depth, the physicists have devised a series of experiments. As the mose important foundation of these experiments is to control the generation of X family nucleuses, and figure out the instant minimum weight difference among them, the physicists feel like devising a special device which can carry out different kinds of instructions and accomplish the task above. Here are 3 kinds of instructions in desire: - generate M Suppose the weights of nucleuses are numbers starting from 1, and M is a positive integer, then the device should produce a nucleus weighted M. If there already exists a nucleus with the same weight, then this instruction should not be taken into account. - remove M Suppose M is a positive integer, then the device should remove the existing nucleus weighted M. If no such nucleus exists, the instruction should also be ignored. Please note that a nuclues can exist all the same unless it’s removed by the device. - query The device should output the instant minimum weight difference among those existing nucleuses. For example, if there exists 3 nucleuses weight 1, 7, 10 respectively, then the minimum weight difference is 10-7=3. If there is less than 2 nucleuses with different weight, the query result should be "-1" (without quotes). Now, your task is to write a program to simulate this special device. 输入Input may contain multiple test cases. The first line is a positive integer t, the number of test cases below. For each case, the input is an instruction sequence. The first line is a single integer n, ( 1 ≤ n ≤ 100 000 ), denoting the number of instructions in this case. And n instructions follow. Each of them is one of the three kinds of instruction as described above, where M is a positive integer no more than 100000. 输出Description Recently the physicists have been investigating a large family of atomic nucleuses, named "X family". They have discovered that these atomic nucleuses in X family are quite similar to each other, and can only be distinguished by their weights. And the smaller the weight difference between two kinds of nucleuses is, the more possibly one kind tend to transform to the other.To research X family in depth, the physicists have devised a series of experiments. As the mose important foundation of these experiments is to control the generation of X family nucleuses, and figure out the instant minimum weight difference among them, the physicists feel like devising a special device which can carry out different kinds of instructions and accomplish the task above. Here are 3 kinds of instructions in desire: - generate M Suppose the weights of nucleuses are numbers starting from 1, and M is a positive integer, then the device should produce a nucleus weighted M. If there already exists a nucleus with the same weight, then this instruction should not be taken into account. - remove M Suppose M is a positive integer, then the device should remove the existing nucleus weighted M. If no such nucleus exists, the instruction should also be ignored. Please note that a nuclues can exist all the same unless it’s removed by the device. - query The device should output the instant minimum weight difference among those existing nucleuses. For example, if there exists 3 nucleuses weight 1, 7, 10 respectively, then the minimum weight difference is 10-7=3. If there is less than 2 nucleuses with different weight, the query result should be "-1" (without quotes). Now, your task is to write a program to simulate this special device. Input Input may contain multiple test cases. The first line is a positive integer t, the number of test cases below. For each case, the input is an instruction sequence. The first line is a single integer n, ( 1 ≤ n ≤ 100 000 ), denoting the number of instructions in this case. And n instructions follow. Each of them is one of the three kinds of instruction as described above, where M is a positive integer no more than 100000. Output For each test case, each query instruction should correspond to one line of output, containing only one positive integer, which is the corresponding query result. Please output a blink line between test cases. Sample Input 1 Sample Output -1 Source 样例输入1 样例输出-1 作者 |