#include #include using namespace std; const double err = 0.000000001; const double M = 1000000.0; struct myStack{ int p; myStack *next; }; myStack *S; int n,b; double x[100],y[100], totalpts[100]; bool hull[100]; double OneBoard[100][100], Best[100][100]; void PUSH( int p0){ myStack *newnode = new myStack; newnode->p = p0; newnode->next = S; S = newnode; } void POP(){ S = S->next; } void printStack(){ myStack *P = S; while(P!=NULL){ cout<p<<' '; P=P->next; } cout<>x[i]>>y[i]; } bool LHangle(int p0, int p1, int p2){ double x0,y0,x1,y1,x2,y2; x0=x[p0]; y0=y[p0]; x1=x[p1]; y1=y[p1]; x2=x[p2]; y2=y[p2]; if((y1-y0)/(x1-x0) < (y2-y1)/(x2-x1) + err) return true; else return false; } void markConvexHull(){ for (int i=0;i3 && LHangle(0,1,2)) // pt 1 is not on hull { POP(); POP(); PUSH(2); } for(int i=3;inext->p,S->p,i)) {POP(); if(S->next ==NULL) break;} PUSH(i); } //handle special case when n<=3 if(n==3 && LHangle(0,1,2)) // pt 1 is not on hull { POP(); POP(); PUSH(2); } //stack S contains points on convex hull myStack *P = S; while(P!=NULL){ hull[P->p] = true; P=P->next; } //compute totalpts[i] = # convex pts 0..i for(int i=0;i Max) Max = slope*x[k] + intercept -y[k]; if (Max < err) Max = 0.0; if(Maxi){ if(OneBoard[i][j]==M) cout<<'M'<<' '; else cout<OneBoard[j+1][i]) maxi = Best[k-1][j]; else maxi = OneBoard[j+1][i]; if(maxi>n>>b; while(n>0){ getPoints(n); markConvexHull(); for(int i=0;i>n>>b; } return 0; }