The linear correlation of matrices can be associated.
According to test instructions, the desired alloy should be in a convex package of the material.
And the requirements are convex hull of the edges as little as possible.
Build the shortest way to run Floyd.
Each time the judgment point is on the left side of the line segment, the second judgment is to determine if the collinear points are on the line segment.
By: Big Brother
1#include <bits/stdc++.h>2 #defineEPS 1e-73 #defineN 5104 using namespacestd;5 structnode{6 Doublex, y, z7 }a[n],b[n];8 node Vet (node A,node b)9 {TenNode c;c.x=a.x-b.x;c.y=a.y-b.y; One returnC; A } - DoubleXmul (node A,node b) {returna.x*b.y-b.x*a.y;} - DoublePmul (node A,node b) {returna.x*b.x+a.y*b.y;} the intN,m,ans,f[n][n]; - voidFloyd () - { -ans=1e9; + for(intk=1; k<=n;++k) - for(intI=1; i<=n;++i) + for(intj=1; j<=n;++j) AF[i][j]=min (f[i][j],f[i][k]+f[k][j]); at for(intI=1; i<=n;++i) ans=min (ans,f[i][i]); - } - intMain () - { -scanf"%d%d",&n,&m); -Memset (F,0x3f,sizeof(f)); in for(intI=1; i<=n;++i) scanf ("%LF%LF%LF",&a[i].x,&a[i].y,&a[i].z); - for(intI=1; i<=m;++i) scanf ("%LF%LF%LF",&b[i].x,&b[i].y,&b[i].z); to for(intI=1; i<=n;++i) + for(intj=1; j<=n;++j) - { the BOOLflag=0; * for(intk=1; k<=m;++k) $ {Panax Notoginseng Doublecross=Xmul (Vet (a[i],b[k]), vet (A[j],b[k])); - if(cross>eps) {flag=1; Break;} the if(Fabs (Cross) <eps&&pmul (Vet (a[i],b[k]), vet (A[j],b[k])) >EPS) +{flag=1; Break;} A } the if(!flag) f[i][j]=1; + } - Floyd (); $ if(ANS==1E9) puts ("-1"); $ Elseprintf"%d", ans); - return 0; -}
BZOJ1027 [JSOI2007] alloy