The Magic algorithm and example of the minimum covering circle

Source: Internet
Author: User

Recently Xiang Brother Lectures on computational geometry This magical thing. Then a bunch of new high-class high-innovation classes, and then we a bunch of second day zz full of crazy.

But this is a refreshing thing to say at first.

The original randomization algorithm so strong? Okay, let's see this. Algorithm-- stochastic increment method

A look at the name will know that the input points must be scrambled to make it randomized. Metaphysics

Then there is the enumeration point \ (i\)starting from the first point, and if the current enumerated point is inside the circle, continue without the tube (obviously). Otherwise, the point is the Center radius of \ (0\) to start the enumeration \ (J (1\le J < i) \) .

If \ (j\) is outside the current circle, take the point \ (i\) and point \ (j\) to the center, half of the distance is the radius (the minimum covering circle of two points). With this circle again enumerate \ (k (1\le k<j) \), and then if Point \ (k\) is outside the circle (this is the same as above). The minimum cover circle is calculated with \ (i,j,k\) three points.

And this minimum cover circle is the smallest cover circle of the front \ (i\) points.

Then the biggest problem lies in the process of finding the center and radius of the circle at three o ' Know . This gives a weak and weak analytic geometry method for computational geometry. I'm not.

We need to know a formula about the circle first:

\ (x^2+y^2=r^2\)

Then we set the coordinates of the center as \ ((x_0,y_0) \) and then we can list a ternary two-time equation to solve the value of \ (x_0,y_0\) .

But the specific solution is too technical to find a super-detailed solution. Please refer carefully.

And then just be steadfast in believing that you are Ouhuang and then not being card precision

But this complexity is Metaphysics \ (O (n) \)(Specific proof reference Dalao ' s blog)

The board (that is, the min_cover_circle中文版level was too low)

inlineDB Power (db x) {returnX*x;}inlineDB Dis (node A,node b) {returnsqrt (Power (a.x-b.x) +power (A.Y-B.Y));}inline BOOLIn_circle (Node A) {returnDis (a,o) <=r?1:0;}inline intCalc (DB a,db b,db c,db d,db e,db f) {o.x= (b*f-d*e)/(B*C-A*D); o.y= (c*e-a*f)/(B*C-A*D);}inline voidMin_cover_circle (void){Register intI,j,k; Random_shuffle (A+1, A+n+1); for(i=1; i<=n;++i)if(!in_circle (A[i])) {O=a[i]; r=0; for(j=1; j<i;++j)if(!in_circle (A[j])) {o.x= (a[i].x+a[j].x)/2.0; o.y= (A[I].Y+A[J].Y)/2.0; R=dis (A[i],o); for(k=1; k<j;++k)if(!in_circle (A[k])) Calc (A[i].x-a[j].x,a[i].y-a[j].y,a[i].x-a[k].x,a[i].y-a[k].y, (Power (a[i].x)-power (a[j].x)) -(Power (A[J].Y)-power (A[I].Y))/2.0, ((Power (a[i].x)-power (a[k].x))-(Power (A[K].Y)-power (A[I].Y))/2.0), R=dis (A[i],o); }    }}

The last found O is the origin, r is the radius.

Then we'll look at some board questions:

HDU3007

The data range of this problem is very small. Although we can be too violent (O (n^3) \) , the new algorithm still has to be practiced.

bzoj1336&&bzoj1337&&bzoj2823

Bzoj's data strength is higher, but that magic precision problem is ...

The sample retains two bits, in fact to retain 10 bits, the title is not said. Is this the range of data that we're guessing?

Luogu P1742 Minimum Circle cover &&luogu P2533 [AHOI2012] Signal Tower

And Bzoj Basic is the re-title, but thanks to Rokua to understand the data range.

Inexplicably got a metaphysical province selection algorithm . It's still pretty good.

The Magic algorithm and example of the minimum covering circle

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.