Rokua P1378 Oil Droplet expansion

Source: Internet
Author: User
Tags abs
Title Description
In 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. Then, in what order should the oil droplets be placed on these n points, in order to make all the oil droplets occupy the overall product maximum.
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 Sample # #:
2
0
3
17 7
Sample # # of output:
50
Ideas
Preprocess out points with the edges and the rest of the distance, DFS, note that only the oil droplets that have been placed will have an effect.
#include <cstdio> #include <cmath> using namespace std;
int n,x,y,xx,yy,a[100],b[100];
Double F[100][100],max;
BOOL t[100];
    Double min (double v,double e) {if (v<e) return v;
else return e;
    } int abs (int v) {if (v<0) return-v;
else return v;
        } int Sqr (int c) {return c*c;} int ss (int c,double p) {if (c>n) {if (P>max) max=p;
    return 0;
            } for (int i=1;i<=n;i++) {if (T[i]) {t[i]=false;
            Double o=0;
            O=min (ABS (A[I]-X), ABS (Xx-a[i));
            O=min (O,abs (b[i]-y));
            O=min (O,abs (yy-b[i));
                for (int j=1;j<=n;j++) {if (f[i][j]<=0) o=min (f[i][j],o);
            if (not T[j]) o=min (f[i][j],o);
                } if (o<=0) {t[i]=true;
            SS (C+1,P);
             } else {   for (int j=1;j<=n;j++) {f[i][j]=f[i][j]-o;
                F[J][I]=F[I][J];
                } SS (C+1,p+3.1415926*o*o);
                T[i]=true;
                    for (int j=1;j<=n;j++) {f[i][j]=f[i][j]+o;
                F[J][I]=F[I][J];
    }}}}} int main () {scanf ("%d", &n);
    scanf ("%d%d%d%d", &x,&y,&xx,&yy);
    for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) f[i][j]=0xfffffff;
        for (int i=1;i<=n;i++) {scanf ("%d%d", &a[i],&b[i]);
            for (int k=1;k<i;k++) {f[i][k]=sqrt (SQR (ABS (A[I]-A[K))) +SQR (ABS (B[I]-B[K)));
        F[K][I]=F[I][K];              
    }} for (int i=1;i<=n;i++) t[i]=true;
    SS (1,0);
    Max=abs (xx-x) *abs (yy-y)-max;  
printf ("%d", int (max+0.5)); }

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.