http://www.lydsy.com/JudgeOnline/problem.php?id=1027
And then listen to the next door next to the future Ioi ye Orzccz
Because the third dimension can be launched from the first two dimensions, it becomes a bit
Then the title can be translated into a minimum convex polygon so that all points are within this convex polygon
And then we can Floyd.
For two of the alloy of the raw material, two points in the coordinate system, if all the required alloys are on its side (it may be set to the left side uniformly), a forward edge with a length of 1 is attached.
1#include <cstdio>2#include <iostream>3#include <cstring>4#include <algorithm>5#include <cmath>6 #defineRep (i,l,r) for (int i=l;i<=r;++i)7 using namespacestd;8 Const intn=520;9typedefDoubleD;Ten intN,m,ans,f[n][n],flag; One d C; A structpoint{ - d x, y; - }a[n],b[n]; the typedef point Vector; - ConstD eps=1e-7; -Vectoroperator-(Point A,point b) { - return(vector) {a.x-b.x,a.y-b.y}; + } - d Cross (vector a,vector b) { + returna.x*b.y-a.y*b.x; A } at D Cross (Point A,point b,point c) { - returnCross (b-a,c-a); - } - d dot (vector a,vector b) { - returna.x*b.x+a.y*b.y; - } in d dot (point A,point b,point c) { - returnDot (b-a,c-a); to } + intMain () { -scanf"%d%d",&n,&m); theRep (I,1, N) scanf ("%LF%LF%LF",&a[i].x,&a[i].y,&c); *Rep (I,1, m) scanf ("%LF%LF%LF",&b[i].x,&b[i].y,&c); $Memset (F, -,sizeoff);Panax NotoginsengRep (I,1, N) Rep (J,1, N) { -flag=1; theRep (K,1, M) { +C=Cross (B[k],a[i],a[j]); A if(c>eps| | (Fabs (c) <eps&&dot (B[k],a[i],a[j]) >EPS)) { theflag=0; + Break; - } $ } $ if(flag) f[i][j]=1; - } -Rep (K,1, N) Rep (I,1, N) Rep (J,1, N) f[i][j]=min (f[i][j],f[i][k]+f[k][j]); theans=1e9; -Rep (I,1, N) ans=min (ans,f[i][i]);Wuyiprintf"%d\n", ans>=1e9?-1: ans); the}
View Code
bzoj1027: [JSOI2007] Alloy