{"trustable":false,"sections":[{"title":"","value":{"format":"PLAIN","content":"Shanghai Hypercomputers, the world\u0027s largest computer chip manufacturer, has invented a new classof nanoparticles called Amphiphilic Carbon Molecules (ACMs). ACMs are semiconductors. It means that they can be either conductors or insulators of electrons, and thus possess a property that is very important for the computer chip industry. They are also amphiphilic molecules, which means parts of them are hydrophilic while other parts of them are hydrophobic. Hydrophilic ACMs are solublein polar solvents (for example, water) but are insoluble in nonpolar solvents (for example, acetone).Hydrophobic ACMs, on the contrary, are soluble in acetone but insoluble in water. SemiconductorACMs dissolved in either water or acetone can be used in the computer chip manufacturing process.\n\nFig.1\n\nAs a materials engineer at Shanghai Hypercomputers, your job is to prepare ACM solutions from ACM particles. You go to your factory everyday at 8 am and find a batch of ACM particles on your workbench. You prepare the ACM solutions by dripping some water, as well as some acetone, into those particles and watch the ACMs dissolve in the solvents.You always want to prepare unmixed solutions, so you first separate the ACM particles by placing an Insulating Carbon Partition Card (ICPC) perpendicular to your workbench. The ICPC is long enough to completely separate the particles. You then drip water on one side of the ICPC and acetone on the other side. The ICPC helps you obtain hydrophilic ACMs dissolved in water on one side and hydrophobic ACMs dissolved in acetone on the other side. If you happen to put the ICPC on top of some ACM particles, those ACMs will be right at the border between the water solution and the acetone solution,and they will be dissolved. Fig.1 shows your working situation.Your daily job is very easy and boring, so your supervisor makes it a little bit more challenging by asking you to dissolve as much ACMs into solution as possible. You know you have to be very careful about where to put the ICPC since hydrophilic ACMs on the acetone side, or hydrophobic ACMs on the water side, will not dissolve. As an experienced engineer, you also know that sometimes it can be very difficult to find the best position for the ICPC, so you decide to write a program to help you. You have asked your supervisor to buy a special digital camera and have it installed above your workbench,so that your program can obtain the exact positions and species (hydrophilic or hydrophobic) of each ACM particle in a 2D pictures taken by the camera. The ICPC you put on your workbench will appearas a line in the 2D pictures.\n\nInput\n\nThere will be no more than 10 test cases. Each case starts with a line containing an integer N, which is the number of ACM particles in the test case.N lines then follow. Each line contains three integers x,y,r, where (x;y) is the position of the ACM particle in the 2D picture and r can be 0 or 1, standing for the hydrophilic or hydrophobic type ACM respectively. The absolute value of x,y will be no larger than 10000. You may assume that N is no more than 1000.N\u003d 0 signifies the end of the input and need not be processed.\n\nOutput\n\nFor each test case, output a line containing a single integer, which is the maximum number of dissolved ACM particles.Note:Fig.2 shows the positions of ACM particles and the best ICPC position for the last test case inthe sample input.\n\nFig.2\n\nSample Input\n\n3\n0 0 0\n0 1 0\n2 2 1\n4\n0 0 0\n0 4 0\n4 0 0\n1 2 1\n7\n-1 0 0\n1 2 1\n2 3 0\n2 1 1\n0 3 1\n1 4 0\n-1 2 0\n0\n\nSample Output\n\n3\n3\n6\n\n全球最大的计算机芯片制造商上海超算发明了一类新的纳米颗粒,称为两亲碳分子(ACMs)。ACMs是一种半导体。这意味着它们既可以是电子的导体,也可以是电子的绝缘体,因此具有对计算机芯片行业非常重要的特性。它们也是两亲分子,这意味着它们的一部分是亲水的,而其他部分是疏水的。亲水性ACMs可溶于极性溶剂(如水),但不溶于非极性溶剂(如丙酮),而疏水性ACMs则相反,可溶于丙酮而不溶于水。溶解在水或丙酮中的半导体ACMs可用于计算机芯片制造过程。\n\n图1\n\n作为上海超算的一名材料工程师,你的工作是用ACM颗粒制备ACM溶液。你每天早上8点去工厂,发现工作台上有一批ACM颗粒。 你准备ACM溶液的方法是在这些颗粒中滴入一些水,以及一些丙酮,并观察ACMs在溶剂中的溶解情况。你总是想准备未混合的溶液,所以你首先将一个绝缘碳隔板(ICPC)垂直放置在你的工作台上,以分离ACM颗粒。ICPC的长度足以完全分离颗粒。然后,您在ICPC的一侧滴上水,在另一侧滴上丙酮。ICPC可以帮助您获得一面溶解在水中的亲水性ACMs和另一面溶解在丙酮中的疏水性ACMs。如果把ICPC放在一些ACM颗粒上,这些ACM就会在水溶液和丙酮溶液的边界处被溶解。图1是你的工作情况,你每天的工作非常简单和枯燥,所以你的上司让你尽可能多地将ACM溶解到溶液中,这就增加了一点挑战性。你知道你必须非常小心地把ICPC放在哪里,因为亲水的ACMs在丙酮一侧,或者疏水的ACMs在水一侧,都不会溶解。作为一个有经验的工程师,你也知道有时要找到ICPC的最佳位置是非常困难的,所以你决定编写一个程序来帮助你。你让你的主管买了一台特殊的数码相机,并把它安装在你的工作台上面,这样你的程序就可以从相机拍摄的二维图片中获得每个ACM颗粒的准确位置和种类(亲水或疏水)。您放在工作台上的ICPC将在二维图片中显示为一条线。\n\n输入内容\n\n测试用例不会超过10个。每一个案例都以一个包含整数N的行开始,这是测试案例中ACM粒子的数量,然后是N行。每行包含三个整数x,y,r,其中(x;y)是ACM粒子在2D图片中的位置,r可以是0或1,分别代表亲水型或疏水型ACM。x,y的绝对值不会大于10000。可以假设N不超过1000,N\u003d0表示输入结束,无需处理。\n\n輸出結果\n\n对于每个测试案例,输出一行包含一个整数,即ACM颗粒的最大溶解数。注:图2显示了最后一个测试案例输入的ACM颗粒位置和最佳ICPC位置。\n\n图2是最后一个测试案例的ACM颗粒位置和最佳ICPC位置。\n\n样品输入\n\n3\n0 0 0\n0 1 0\n2 2 1\n4\n0 0 0\n0 4 0\n4 0 0\n1 2 1\n7\n-1 0 0\n1 2 1\n2 3 0\n2 1 1\n0 3 1\n1 4 0\n-1 2 0\n0\n\n采样输出\n\n3\n3\n6\n\n"}}]}