3126 Nova //2009 Asia Wuhan Regional Contest Online //MAXMATCH
来源:互联网 发布:淘宝卖檀香 编辑:程序博客网 时间:2024/06/15 19:25
Nova
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 564 Accepted Submission(s): 134
The first line of each case consists of three integers N, M, K, indicating the number of lich, the number of wisps and the number of trees. The next N lines, each line consists of four integers x, y, r, t indicating the coordinate of that a lich, the radius of the attack range that lich’s Frost Nova can reach and the value of cool down time. The next M lines, each line consists of two integers x, y indicating the coordinate of each wisp. The last K lines, each line consists of three integers x, y, r, indicating the coordinate and radius of a tree. A lich cannot attack a wisp if the segment between them has a common point with the tree. The lich, wisp and trees will not overlap with each other.
Constrains
0 < T <= 20
0 <= N, M, K <= 200
-10000 <= x, y <= 10000
0 <= r, t <= 10002
12 3 1-100 0 100 3100 0 100 5-100 -10100 10110 115 5 10
5
#include<cstdio>
#include<cstring>
#include<cmath>
const int maxint = 0x7FFFFFFF;
const int maxn = 200 + 5;
const double eps = 1e-8;
int sgn(double x)
{
return (x>eps) - (x<-eps);
}
struct Point
{
double x, y;
Point() {}
Point(double _x, double _y): x(_x), y(_y) {}
Point operator + (const Point &a) const { return Point(x + a.x, y + a.y);}
Point operator - (const Point &a) const { return Point(x - a.x, y - a.y);}
double operator * (const Point &a) const{ return x * a.y - y * a.x;}
double dot(const Point &a) const{ return x * a.x + y * a.y; }
double lenth() const { return sqrt(dist());}
double dist() const { return x * x + y * y;}
void input(){ scanf("%lf%lf", &x, &y);}
void output() const{ printf("%lf %lf/n", x, y);}
};
int mat[maxn], now[maxn], r[maxn], t[maxn], br[maxn];
bool used[maxn], g[maxn][maxn];
int n, m, c;
Point lich[maxn], tree[maxn], wisp[maxn];
double cross(const Point &a, const Point &b, const Point &c)
{
return (b-a)*(c-a);
}
bool nova(const Point &a, const Point &b, double r)
{
if (sgn((a-b).dist()-r*r)>0) return false;
for (int i=0;i<c;++i)
{
if (sgn(fabs(cross(a,b,tree[i])) / (a-b).lenth()-br[i]) > 0) continue;
if (sgn((tree[i]-a).dot(b - a))<0 || sgn((tree[i]-b).dot(a-b))<0) continue;
return false;
}
return true;
}
bool find(int x)
{
for(int i=0;i<m;i++)
if(!used[i] && g[x][i])
{
used[i]=true;
if(mat[i]==-1 || find(mat[i]) )
{
mat[i]=x;
return true;
}
}
return false;
}
void match()
{
memset(mat,-1,sizeof(mat));
memset(now,0,sizeof(now));
int cnt=0,ans=0;
while(cnt<m)
{
int v=-1;
for(int i=0;i<n;++i)
{
if(now[i]==maxint) continue;
if(v==-1 || now[i]<now[v] ) v=i;
}
if(v==-1) break;
memset(used,0,sizeof(used));
if(find(v))
{
ans=now[v];
now[v]+=t[v];
cnt++;
}
else now[v]=maxint;
}
if (cnt == m) printf("%d/n", ans);
else printf("-1/n");
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d",&n,&m,&c);
for(int i=0;i<n;i++)
{
lich[i].input();
scanf("%d%d",&r[i],&t[i]);
}
for(int i=0;i<m;i++) wisp[i].input();
for(int i=0;i<c;i++)
{
tree[i].input();
scanf("%d",&br[i]);
}
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
g[i][j]=nova(lich[i],wisp[j],r[i]);
match();
}
return 0;
}
- 3126 Nova //2009 Asia Wuhan Regional Contest Online //MAXMATCH
- HDU 3126 Nova [2009 Asia Wuhan Regional Contest Online]
- hdu 3123 2009 Asia Wuhan Regional Contest Online
- hdu 3123 GCC (2009 Asia Wuhan Regional Contest Online)
- hdu oj 3127 WHUgirls(2009 Asia Wuhan Regional Contest Online)
- hdu oj 3125 Slash (2009 Asia Wuhan Regional Contest Online)
- Box Relations //2009 Asia Wuhan Regional Contest Hosted by Wuhan University 拓扑排序
- 3233 Download Manager //2009 Asia Wuhan Regional Contest Hosted by Wuhan University
- 简单题 —— Crossing Rivers —— 2009 Asia Wuhan Regional Contest Hosted by Wuhan University
- 2011 Asia Beijing Regional Online Contest-1005 hdu4044 GeoDefense
- 2011 Asia Beijing Regional Online Contest-1007 hdu4046 Panda
- 2011 Asia Beijing Regional Online Contest-1002 hdu4041 Eliminate Witches!
- 2011 Asia Beijing Regional Online Contest-1010 hdu4049 Tourism Planning
- 2011 Asia Beijing Regional Online Contest-1006 hdu4045 Machine scheduling
- 2011 Asia Beijing Regional Online Contest-1004 hdu4043 FXTZ II
- 2011 Asia Beijing Regional Online Contest-1005 hdu4044 GeoDefense-tjuqxy
- hdu 5045 Contest 2014 ACM/ICPC Asia Regional Shanghai Online
- 2013 ACM/ICPC Asia Regional Changsha Online Contest C
- 性能测试 负载测试 压力测试 容量测试
- 关于vs2005的“应用程序配置不正确,无法运行”问题的解决方法
- PHP 实现多服务器共享 SESSION 数据
- Birt Report Q&A
- Mutex与CRITICAL_SECTION的比较
- 3126 Nova //2009 Asia Wuhan Regional Contest Online //MAXMATCH
- C语言中关于自加的几个小题
- labview下UDP通信
- 原码 反码
- How to Create Dump File for Applications
- 关于Windows内核对象句柄在进程空间内的存储
- 组播与ip地址对应
- BaiduSpider高频率工作时间
- VS2005中Manifest引入的问题