ZOJ 3460 Missile (binary + binary graph matching)

Source: Internet
Author: User

Problem Solving Ideas:

Think of every time a missile can be fired as a launcher, a total of n * m, and then a two-point answer

#include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath > #include <string.h> #include <vector> #include <queue> #include <math.h> #include <set > #include <map> #include <stack> #define LL long long#define for (i, X, y) for (int i=x;i<=y;i++) using name Space Std;const Double EPS = 1e-8;const int maxn = 2500 + 10;int vis[maxn];vector<int>g[60];int MATCH[MAXN];d ouble t [MAXN] [60];struct point{int x, y;}    A[MAXN], B[maxn];int N, m;double t1, T2, v;double dis (point A, point B) {double x = a.x-b.x;    Double y = a.y-b.y; return sqrt (x * x + y * y);}    int path (int u) {int sz = g[u].size ();        for (int i=0;i<sz;i++) {int v = g[u][i];            if (!vis[v]) {vis[v] = 1;                if (match[v] = = 1 | | path (MATCH[V])) {Match[v] = u;            return 1; }}} return 0;}  int Maxmatch () {int res = 0;  memset (Match,-1, sizeof (match));        for (int i=0;i<m;i++) {memset (Vis, 0, sizeof (VIS));    Res + = path (i); } return res;        Double D[maxn][60];int Main () {while (scanf ("%d%d%lf%lf%lf", &n, &m, &t1, &t2, &v)!=eof) {        T1/= 60;        For (i, 0, m-1) scanf ("%d%d", &b[i].x, &AMP;B[I].Y);        For (i, 0, n-1) scanf ("%d%d", &a[i].x, &AMP;A[I].Y);        for (int i=0;i<n;i++) {for (int j=0;j<m;j++) d[i][j] = Dis (a[i], b[j]);                    } for (k, 0, M-1) {for (I, 0, n-1) {for (j, 0, M-1) {                T[I*M+K][J] = k * T2 + (k+1) * t1 + d[i][j]/V;        }}} Double L = 0, r = 2000000000000.0;            while (r-l >= EPS) {Double mid = (L + r) * 0.5;            for (int i=0;i<60;i++) g[i].clear (); for (int i=0;i<n*m;i++) {for (int j=0;j<m;j++) {if (T[i][j] <= mid) g[j].push_back (i);            }} if (Maxmatch () = = m) {r = Mid;        } else L = mid;    } printf ("%.6lf\n", R); } return 0;}

ZOJ 3460 Missile (binary + binary graph matching)

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.