原题链接

首先可以二分答案,然后考虑检验答案。

我们可以对炮塔进行拆点,即能发射\(x\)颗导弹就拆成\(n\times x\)个点,作为一个集合,另一个集合则是\(m\)个侵入者,然后对于能在剩余时间攻击到侵入者的炮弹和该侵入者连边,然后跑匈牙利或网络流求二分图最大匹配即可(本质是多重匹配,使用拆点法)。

#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
const int N = 55;
const int M = 1e6 + 10;
const int K = 1e5 + 10;
struct dd {
double x, y;
};
dd a[N], b[N];
int fi[K], di[M], ne[M], mtc[K], l, t_2, n, m;
double dis[N][N], t_1;
bool v[K];
inline int re()
{
int x = 0;
char c = getchar();
bool p = 0;
for (; c < '0' || c > '9'; c = getchar())
p |= c == '-';
for (; c >= '0' && c <= '9'; c = getchar())
x = x * 10 + c - '0';
return p ? -x : x;
}
inline void add(int x, int y)
{
di[++l] = y;
ne[l] = fi[x];
fi[x] = l;
}
bool dfs(int x)
{
int i, y;
for (i = fi[x]; i; i = ne[i])
if (!v[y = di[i]])
{
v[y] = 1;
if (!mtc[y] || dfs(mtc[y]))
{
mtc[y] = x;
return true;
}
}
return false;
}
bool judge(double mid)
{
int i, j, s = 0, k = 0;
double T = mid;
memset(fi, 0, sizeof(fi));
memset(mtc, 0, sizeof(mtc));
l = 0;
while (T >= t_1)
{
T -= t_1;
k++;
for (i = 1; i <= m; i++)
for (j = 1; j <= n; j++)
if (dis[j][i] <= T)
add(i, (k - 1) * n + j);
T -= t_2;
}
for (i = 1; i <= m; i++)
{
memset(v, 0, sizeof(v));
if (dfs(i))
s++;
}
return !(s ^ m);
}
int main()
{
int i, j, x, y, V;
double l, r = 3e4, mid;
n = re();
m = re();
l = t_1 = re() * 1.0 / 60;
t_2 = re();
V = re();
for (i = 1; i <= m; i++)
{
a[i].x = re();
a[i].y = re();
}
for (i = 1; i <= n; i++)
{
x = re();
y = re();
for (j = 1; j <= m; j++)
dis[i][j] = sqrt(1.0 * (x - a[j].x) * (x - a[j].x) + 1.0 * (y - a[j].y) * (y - a[j].y)) / V;
}
while (l + 1e-7 < r)
{
mid = (l + r) / 2;
if (judge(mid))
r = mid;
else
l = mid;
}
printf("%.6f", r);
return 0;
}

JoyOI1935 导弹防御塔的更多相关文章

  1. bzoj3035: 导弹防御塔

    Description Freda的城堡——“Freda,城堡外发现了一些入侵者!”“喵...刚刚探究完了城堡建设的方案数,我要歇一会儿嘛lala~”“可是入侵者已经接近城堡了呀!”“别担心,rain ...

  2. 「Poetize3」导弹防御塔

    描述 Description Freda控制着N座可以发射导弹的防御塔.每座塔都有足够数量的导弹,但是每座塔每次只能发射一枚.在发射导弹时,导弹需要T1秒才能从防御塔中射出,而在发射导弹后,发射这枚导 ...

  3. [tyvj1935 Poetize3]导弹防御塔 (二分图多重匹配)

    传送门 Description Freda控制着N座可以发射导弹的防御塔.每座塔都有足够数量的导弹,但是每座塔每次只能发射一枚.在发射导弹时,导弹需要T1秒才能从防御塔中射出,而在发射导弹后,发射这枚 ...

  4. CH6803 导弹防御塔

    6803 导弹防御塔 0x60「图论」例题 背景 Freda的城堡-- "Freda,城堡外发现了一些入侵者!" "喵...刚刚探究完了城堡建设的方案数,我要歇一会儿嘛l ...

  5. 【NOIP2013模拟】导弹防御塔

    题目 Freda的城堡-- "Freda,城堡外发现了一些入侵者!" "喵...刚刚探究完了城堡建设的方案数,我要歇一会儿嘛lala~" "可是入侵者 ...

  6. Codevs2490 导弹防御塔

    2490 导弹防御塔 2490 导弹防御塔 时间限制: 1 s 空间限制: 64000 KB 题目等级 : 大师 Master         题目描述 Description Freda的城堡—— ...

  7. contest hunter 6803 导弹防御塔

    没什么好写的.写写这题吧 拆点,把一个防御塔拆成m个,表示第i次攻击.瞎yy就好啊 #include<cstdio> #include<iostream> #include&l ...

  8. joyoi1935 「Poetize3」导弹防御塔

    #include <iostream> #include <cstring> #include <cstdio> #include <queue> #i ...

  9. 【CH6803】导弹防御塔

    题目大意:给定 N 座塔,M 个怪物,每座塔一次可以发射一枚导弹,发射导弹有发射时间和冷却时间,每座塔和每只怪物有自己的二维坐标,所有导弹有一个共同的速度,求至少需要多长时间才能将所有怪物消灭. 题解 ...

随机推荐

  1. STOP OUR NEGATIVE THOUGHTS

    Do you ever feel like you're in over your head and at any moment you're going to burst? You're not a ...

  2. oracle wm_concat() 返回空

    参考 https://www.cnblogs.com/zengweiming/archive/2013/11/20/3433642.html select wm_concat(to_char(str) ...

  3. centos7安装zabbix3.5

    安装centos7 自带MariaDB数据库(或者安装mysql) yum -y install mariadb-server mariadb-devel systemctlstartmariadb. ...

  4. STL::forward_list

    forward_list(c++11): 内部是一个单链表的实现:但是为了效率的考虑,故意没有 size 这个内置函数. Constructor 六种构造方式default; fill; range; ...

  5. 第九章 词典 (c)散列:散列函数

  6. 第二章 向量(d2)有序向量:二分查找

  7. JavaScript各种继承方式(六):寄生组合继承

    一 原理 用寄生继承来改造组合继承. function Fruit(name){ this.name = name; } Fruit.prototype.eat = function(){ conso ...

  8. RxJS之转化操作符 ( Angular环境 )

    一 map操作符 类似于大家所熟知的 Array.prototype.map 方法,此操作符将投射函数应用于每个值 并且在输出 Observable 中发出投射后的结果. import { Compo ...

  9. 100-days: Seven

    Title: Can baiju, China's sorghum firewater, go global? sorghum n. 高粱 firewater n. 烈酒 Baijiu——a broa ...

  10. nSamplesPerSec和nAvgBytesPerSec

    nAvgBytesPerSec 意思是每秒多少字节,你的每个sample位深(精度/bitpersample)是16bit,就是2字节,nSamplesPerSec一秒44100个sample(441 ...