poj 1873 The Fortified Forest


タイトル接続:http://poj.org/problem?id=1873
Time Limit: 1000 MS
 
メモリLimit: 30000 K
Total Submissions: 8124
 
Acceepted: 2232
Description
Onice upaon a time、in a faraway land、there lived a king.Thisking owned a sssmaalcollection of rare and valuable trees、which had been gathered by his ancestors on theirtrtrtrtravels. Toprotetehit Alsthis trees frererestststststststststststststststststrererererererererererererererererererererererererereeeeeeeeeees.aaaath.tototothethethethethethethethethethethethethethethethethethethethethethethethethethethethethethe wizard quickly noticed that the only suitable available to build the fence was the wood from the mselves.In others wors、it necessary to cut down some treers the the ders the fererever.netthe wizard wanted to minimize the value of the trees that to be cut.The wizard went to his towers and stayed the until the best possible to solution to the problem.The fence wars then built and velifter
Input
The input contains several test cases、each of which describes a hypothetical forest.Each test case begis begis beinininininininininintegern、2<=n==15、the number of trees the forest.Thetreeeininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininininを選択します。li that describe a single tree.(xi,yi)is the position of the tree in the pline,vi is its value,and li is the length of fence that can be built using the wood of the tree.vi and li are between 0 and 10.putense.The
Output
For each test case、computte a subset of the trees such that、using the wood from that subset、the remaning trees can be enclosed ininininininininininininininininininininininststststinininmvalue.If moreree.If motheeeeeeeeeeeeeeeeeeemmmmmststststststststststststststststststststststststststststststststininininininininininininininineeeeeeeeeeeemmmmmmmmmmhaving zero diameter.Display,as shown below,the test case numbers(1,2,…),the identity of each tree to be cut,and the length of the excess fencing.Displate a blank line between test cases.
 
Sample Input
6
 0  0  8  3
 1  4  3  2
 2  1  7  1
 4  1  2  3
 3  5  4  6
 2  3  9  8
3
 3  0 10  2
 5  5 20 25
 7 -3 30 32
0
Sample Output
Forest 1
Cut these trees: 2 4 5 
Extra wood: 3.16

Forest 2
Cut these trees: 2 
Extra wood: 15.00
いくつかの木の座標をあげます。今はこれらの木を囲みます。囲いの柵はちょうど木を切る必要があります。今はどの木を切るべきですか?
考え方:一本の木と二本の木しかない場合に注意して、残りの注意点:第一点:これらの木を囲む第二点:価値は一番小さいです。
値が同じ時に切る木の最小の方案は最大15本の木ですから、私達は木の状態を暴力的に列挙すればいいです。最後に改行に注意して、c++を使って渡せばいいです。 
コード:
/*
    :        ,          ,             ,    ,                 

  :             ,     :
   :      
   :     
    15                 
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f
#define bug  printf("bug
") const int maxn=1e2+10; const double pi=acos(-1.0); const double esp=1e-6; const int N=2e2+10; int sign(double x) { if(x==0) return 0; return x>esp?1:-1; } struct point { double x,y; double val,len; point () {} point(double _x,double _y) { x=_x; y=_y; } point operator -(const point &b)const { return point(x-b.x,y-b.y); } double operator *(const point &b)const { return x*b.x+y*b.y; } double operator ^(const point &b)const { return x*b.y-y*b.y; } }; double dis(point a,point b) { return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); } struct line { point st,ed; double k,b; line() {} line(point _s,point _e) { st=_s,ed=_e; k=atan2(ed.y-st.y,ed.x-st.x); } point operator&(const line &b)const { point res=st; double t=((st-b.st)^(b.st-b.ed))/((st-ed)^(b.st-b.ed)); res.x+=(ed.x-st.x)*t; res.y+=(ed.y-st.y)*t; return res; } }; double cmult(point a,point b,point c) { return (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y); } point p[maxn],p1[maxn]; int Stack[maxn],top; bool cmp(point a,point b) { int ju=cmult(p[0],a,b); if(ju>0) return 1; else if(ju==0&&dis(a,p[0])p[i].y||(p0.x==p[i].x&&p0.y==p[i].y)) { p0=p[i]; k=i; } } swap(p[k],p[0]); sort(p+1,p+n,cmp); for(int i=0; i<2; i++) Stack[i]=i; top=1; for(int i=2; i0&&cmult(p[Stack[top-1]],p[Stack[top]],p[i])<=0) top--; top++; Stack[top]=i; } double len=0; for(int i=0; inowval) { minval=nowval; minlen=nowlen; lastcut=nowcut; for(int i=0; inowval) { minval=nowval; minlen=nowlen-len; lastcut=nowcut; for(int i=0; inowcut) { minval=nowval; minlen=nowlen-len; nowcut=lastcut; for(int i=0; i