BZOJ1027 [JSOI2007] Alloy

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.