[Luo gu P1378] oil droplet expansion

Source: Internet
Author: User

Title Description DescriptionIn a rectangular frame, a maximum of N (0≤n≤6) of different points, at any one of the points placed a very small oil droplets, then the oil droplets will continue to expand until exposed to other oil droplets or frame boundaries. You must wait for an oil droplet to expand before you can place the next drop of oil. So what is the order in which to place the oil droplets on these n points, in order to make all the oil droplets occupy the overall product maximum? (different oil droplets do not fuse with each other)
Note: The Circle area Formula V=pi*r*r, where r is the radius of the circle. input/output format input/output Input Format:
Line 1th an integer n.
2nd Behavior Rectangle Border The coordinates of a vertex and its diagonal vertices, x,y,x ', y '.
Next n rows, two integers per line, xi,yi, representing the coordinates of the box's n points.
All of the above data is within [ -1000,1000].
output Format:
A row, an integer, the smallest space remaining in a rectangular box (results rounded out) input and Output sample sample Input/output sample Test point # # Input Sample:

2
20 0 10 10
13 3
17 7

Sample output:

50

Analysis: No number analysis of ... Big storm search Ah ... dfs out-of-order, calculated for each case. When calculating the minimum radius, don't forget to include the case, that is, the center of the circle is covered by another circle.

#include <iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>#include<vector>#include<cmath>using namespacestd;Const DoublePi=3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;Doublex[Ten],y[Ten],r[Ten],MAXN;inta[Ten],n,sum;BOOLv[Ten];DoublecdintIintj) {       returnsqrt ((X[i]-x[j]) * (X[i]-x[j]) + (Y[i]-y[j]) * (y[i]-y[j]));}voidCalc () {Doubleans=0, Dist;  for(intI=1; i<=n;i++) {R[i]=min (x[a[i]]-x[0],x[n+1]-X[a[i]]); R[i]=min (r[i],y[a[i]]-y[0]); R[i]=min (r[i],y[n+1]-Y[a[i]]);  for(intj=1; j<i;j++) {Dist=CD (A[j],a[i]); R[i]=min (r[i],dist-R[j]); }         if(r[i]<0) r[i]=0;//Critical ans+=pi*r[i]*R[i]; } MAXN=Max (Maxn,ans);}voidDfsintk) {     if(k==n+1) {calc (); return; }      for(intI=1; i<=n;i++)         if(!V[i]) {A[k]=i; V[i]=1; DFS (k+1); V[i]=0; }}voiddoit () {DoubleT; if(x[0]<x[n+1]&&y[0]<y[n+1])return; if(x[0]<x[n+1]&&y[0]>y[n+1]) {T=y[0]; y[0]=y[n+1]; Y[n+1]=T; return; }     if(x[0]>x[n+1]&&y[0]<y[n+1]) {T=x[0]; x[0]=x[n+1]; X[n+1]=T; return; }     if(x[0]>x[n+1]&&y[0]>y[n+1]) {T=x[0]; x[0]=x[n+1]; X[n+1]=T; T=y[0]; y[0]=y[n+1]; Y[n+1]=T; return; }}intMain () {scanf ("%d",&N); scanf ("%LF%LF%LF%LF", &x[0],&y[0],&x[n+1],&y[n+1]); Doit ();    The beginning of the writing is too clumsy, do not care about these details, no use.  for(intI=1; i<=n;i++) scanf ("%LF%LF",&x[i],&Y[i]); memset (V,0,sizeof(v)); Memset (A,0,sizeof(a)); DFS (1); printf ("%.0LF", (x[n+1]-x[0]) * (y[n+1]-y[0])-MAXN); return 0;}

[Luo gu P1378] oil droplet expansion

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.