Description:
shanghai Hypercomputers, the world's largest computer chip manufacturer, has invented a n EW class of nanoparticles called amphiphilic Carbon molecules (ACMS). ACMS is 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 is also amphiphilic molecules, which means parts of them is hydrophilic while other parts of them is hydrophobic. Hydrophilic ACMs is soluble in polar solvents (for example, water) but is insoluble in nonpolar solvents (for example, a Cetone). Hydrophobic ACMs, on the contrary, is soluble in acetone and insoluble in water. Semiconductor ACMs dissolved in either water or acetone can is used in the computer chip manufacturing process.
As a materials engineer at Shanghai Hypercomputers, your job was to prepare ACM solutions from ACM Particles. You go to your factory everyday @ 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 dis Solve in the solvents. You always want to prepare unmixed solutions, so you first separate the ACM particles by placing a insulating Carbon part Ition Card (ICPC) perpendicular to your workbench. The ICPC is a long enough to completely separate the particles. 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'll be is right at the border between the water Solut Ion and the acetone solution, and they'll be dissolved. Fig.1 shows your working sitUation.
Fig.1
Your Daily job is very easy and boring, so Your supervisor makes it a little bit more challenging by asking e as much acms into solution as possible. You know are very careful about where to put the ICPC since hydrophilic ACMs on the acetone side, or Hydrophobi C ACMs on the water side, would 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 the write a program. You have asked your supervisor to buy a special digital camera and has it installed above your workbench, so that your PR Ogram 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 would appear as a line in the 2D pictures.
fig.2
Input
There'll be is no more than test cases. Each case starts with a line containing an integerN, which is the number of the ACM particles in the test case.NLines then follow. Each line contains three integersx,y,R, where(x, y)Is the position of the ACM particle in the 2D picture andRCan is 0 or 1, standing for the hydrophilic or hydrophobic type ACM respectively. The absolute value ofx,ywould be no larger than 10000. Assume thatNis no more than 1000. N = 0Signifies the end of the input and need not be processed. Fig.2 shows the positions of ACM particles and the best ICPC position for the last test case in the sample input.
Output
For each test case, output a line containing a single integer, which is the maximum number of dissolved ACM particles.
Sample Input
3 0 0 0 0 1 0 2 2 1 4 0 0 0 0 4 0 4 0 0 1 2 1 7-1 0 0 1 2 1 2 3 0 2 1 1 0 3 1 1 4 0-1 2 0 0
Sample Output
3 3 6
<span style= "FONT-SIZE:14PX;" ># include <cstdio># include <cmath># include <cstring># include <algorithm>using namespace std;const int MAXN = + 5;struct point{int x, y; Double rad; BOOL operator < (const point &n) const {return rad<n.rad; }}OP[MAXN], P[maxn];int N, Color[maxn];bool left (point a,point B)//Determine if the dot is not on the right side of the segment {return a.x*b.y-a.y*b.x >= 0;} int solve () {int i,j; if (n<=2) return 2; int ans=0; for (i=0;i<n;i++) {int k=0; for (j=0;j<n;j++) {if (j!=i) {p[k].x=op[j].x-op[i].x; P[K].Y=OP[J].Y-OP[I].Y; if (Color[j]) {p[k].x =-p[k].x; p[k].y =-p[k].y;} P[k].rad=atan2 (p[k].y,p[k].x); Calculate the Radian value, where atan2 (y, x); k++; }} sort (p,p+k); Sorts int l=0,r=0,cnt=2 according to radians; Scanning method, with two points as a straight line, scanning the left point; while (l<k) {if (l==r) {r= (r+1)%k; cnt++;} while (R!=l&&left (P[l],p[r])) {r= (r+1)%k; cnt++;} Sweep half plane; cnt--; l++; ans= ans >= cnt? ans:cnt; }} return ans; int main () {//freopen ("A.txt", "R", stdin); while (scanf ("%d", &n) = = 1 && n) {int i; for (i=0;i<n;i++) scanf ("%d%d%d", &op[i].x,&op[i].y,&color[i]); printf ("%d\n", Solve ()); } return 0;} </span>
Amphiphilic Carbon Molecules