{"trustable":false,"sections":[{"title":"","value":{"format":"PLAIN","content":"Background from Wikipedia: \\Set theory is a branch of mathematics created principally by the German mathematician Georg Cantor at the end ofthe 19th century. Initially controversial, set theoryhas come to play the role of a foundational theory in modern mathematics, in the sense of a theory invoked to justify assumptions made in mathematics concerning the existence of mathematical objects(such as numbers or functions) and their properties.Formal versions of set theory also have a foundational role to play as specifying a theoretical idealof mathematical rigor in proofs.\"\n\nGiven this importance of sets, being the basis of mathematics, a set of eccentric theorist set off to construct a supercomputer operating on sets instead of numbers. The initial SetStack Alpha is underconstruction, and they need you to simulate it in order to verify the operation of the prototype.\n\nThe computer operates on a single stack of sets, which is initially empty. After each operation, the cardinality of the topmost set on the stack is output. The cardinality of a set S is denoted {S} and is the number of elements in S. The instruction set of the SetStack Alpha is PUSH,DUP,UNION,INTERSECT,and ADD.\n\nPUSH will push the empty set {} on the stack.\nDUP will duplicate the topmost set (pop the stack, and then push that set on the stack twice).\nUNION will pop the stack twice and then push the union of the two sets on the stack.\nINTERSECT will pop the stack twice and then push the intersection of the two sets on the stack.\nADD will pop the stack twice, add the first set to the second one, and then push the resulting set on the stack.\n\nFor illustration purposes, assume that the topmost element of the stack is\n\nA\u003d{{},{{}}}\n\nand that the next one is\n\nB\u003d{{},{{{}}}}\n\nFor these sets, we have |A|\u003d 2 and |B|\u003d 2. Then:\n\nUNION would result in the set {{},{{}},{{{}}}}. The output is 3.\nINTERSECT would result in the set {{}}. The output is 1.\nADD would result in the set {{},{{{}}},{{},{{}}}}. The output is 3.\n\nInput\n\nAn integer 0\u003c\u003dT\u003c\u003d5 on the first line gives the cardinality of the set of test cases. The first line of each test case contains the number of operations 0\u003c\u003dN\u003c\u003d2000. Then follow N lines each containing one of the five commands. It is guaranteed that the SetStack computer can execute all the commands in the sequence without ever popping an empty stack.\n\nOutput\nFor each operation specified in the input, there will be one line of output consisting of a single integer.This integer is the cardinality of the topmost element of the stack after the corresponding commandhas executed. After each test case there will be a line with `***\u0027 (three asterisks).\n\nSample Input\n\n2\n9\nPUSH\nDUP\nADD\nPUSH\nADD\nDUP\nADD\nDUP\nUNION\n5\nPUSH\nPUSH\nADD\nPUSH\nINTERSECT\n\nSample Output\n\n0\n0\n1\n0\n1\n1\n2\n2\n2\n***\n0\n0\n1\n0\n0\n***\n\n背景来自维基百科。 \\集合论是数学的一个分支,主要由德国数学家格奥尔格-康托尔在19世纪末创立。最初是有争议的,集论在现代数学中扮演着基础理论的角色,在这个意义上,一种理论被用来证明数学中关于数学对象(如数字或函数)的存在及其属性的假设。\"集论的正式版本也有一个基础性的作用,即在证明中规定了一种数学严谨性的理论理想。\"\n\n鉴于集合作为数学基础的这种重要性,一组偏心的理论家开始构造一台在集合上运行的超级计算机,而不是数字。最初的SetStack Alpha正在建造中,他们需要你对它进行模拟,以验证原型机的运行情况。\n\n计算机在单堆集上运行,最初是空的。每次操作后,输出堆栈上最上面的集合的cardinality。集合S的cardinality表示{S},是S中元素的数目。 SetStack Alpha的指令集是PUSH,DUP,UNION,INTERSECT和ADD。\n\nPUSH将把空集{}推到栈上。\nDUP将复制最上面的集合(弹出堆栈,然后将该集合推到堆栈上两次)。\nUNION会弹出堆栈两次,然后把两个集合的联合推到堆栈上。\nINTERSECT将两次弹出堆栈,然后在堆栈上推送两个集合的交叉点。\nADD会弹出堆栈两次,将第一个集合加到第二个集合上,然后将结果的集合推到堆栈上。\n\n为了便于说明,假设堆栈最上面的元素是\n\nA\u003d{{},{{}}}\n\n而下一个是\n\nB\u003d{{},{{{}}}}\n\n对于这些集合,我们有|A|\u003d 2和|B|\u003d 2。那么,对于这些集合,我们有|A|\u003d 2和|B|\u003d 2。\n\nUNION的结果是: {{},{{}},{{{}}}}. 输出为3。\nINTERSECT的结果是集合{{}}。输出为1。\nADD将得到集合{{},{{}},{{},{{}}}}。输出为3。\n\n輸出為3。\n\n第一行的整数0\u003c\u003dT\u003c\u003d5给出了测试用例集的基数。每个测试用例的第一行包含操作数0\u003c\u003dN\u003c\u003d2000。然后跟着N行,每行包含五个命令中的一个。保证SetStack计算机可以执行序列中的所有命令,而不会弹出一个空栈。\n\n輸出\n对于输入中指定的每一个操作,都会有一行由一个整数组成的输出,这个整数是对应的命令执行后堆栈最上面的元素的基数,在每一个测试用例后都会有一行 \"***\"(三个星号)。在每一个测试案例之后,都会有一行带有 \"***\"(三个星号)的内容。\n"}}]}