bzoj1027: [JSOI2007] Alloy

Source: Internet
Author: User

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

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.