Explore more than 3126 Nova // bipartite approximation + Multiple matching

Source: Internet
Author: User
Nova

Time Limit: 1000/1000 MS (Java/others) memory limit: 131072/131072 K (Java/Others)
Total submission (s): 566 accepted submission (s): 135

Problem descriptionthe Lich is a powerful hero that he can kill a wisp with his skill Frost Nova. the Burning Legion wants to conquer the forest so they sent some liches to kill all the wisps. A Lich can kill a wisp once he cocould see the wisp and the wisp in his attack range. so the Lich can attack a wisp when the distance between them is less than or equal to specific R and no trees are on the segment between the Lich and wisp. each Lich has a cool down time that once he used Frost Nova he has to wait a few seconds for the next attack. different liches may have different attack range and cool down time. the Lich King is the leader of the Burning Legion and he wants to arrange the attack order so the liches can wipe out all the wisps as soon as possible.

 

Inputthe first line consists of an integer T, indicating the number of test cases.
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.

 

Outputoutput the minimum time Lich need to kill all the wisps on a single line, or-1 If Lich cannot kill all the wisps.

Constrains
0 <t <= 20
0 <= n, m, and K <= 200
-10000 <= X, Y <= 10000
0 <= r, T <= 10002

 

Sample Input
12 3 1-100 0 100 3100 0 100 5-100 -10100 10110 115 5 10
 

 

Sample output
5
 

 

Source2009 Asia Wuhan Regional Contest online

 

Recommendlcy

 

 

# Include <stdio. h>
# Include <string. h>
# Include <math. h>
Const int maxint = 1 <30-1;
Const double EPS = 1e-8;
Int sign (Double X)
{
Return (x> EPS)-(x <-EPS );
}
Struct point
{
Double X, Y;
Point (){}
Point (double XX, double YY): X (XX), y (yy ){}
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 dist () const {return x * x + y * Y ;}
Double Length () const {return SQRT (Dist ());}
Void input () {scanf ("% lf", & X, & Y );}
Void output () const {printf ("% lf/N", x, y );}
} Lich [201], Wisp [201], tree [201];

Int link [201] [201];
Int n, m, K, Tmax;
Bool flag, used [201];
Int R [201], t [201], TR [201], tnow [201];
Bool G [201] [201];

Bool can (int t)
{
For (INT I = 0; I <n; I ++)
{
If (used [I] = 0 & G [I] [T])
{
Used [I] = 1;
If (link [I] [0] <tnow [I])
{
Link [I] [++ link [I] [0] = T;
Return true;
}
Else
{
For (Int J = 1; j <= link [I] [0]; j ++)
If (CAN (link [I] [J])
{
Link [I] [J] = T;
Return true;
}
}
}
}
Return false;
}

Bool maxmatch (int x)
{
For (INT I = 0; I <n; I ++) tnow [I] = x/T [I] + 1;
For (INT I = 0; I <n; I ++) link [I] [0] = 0;
For (INT I = 0; I <m; I ++)
{
Memset (used, false, sizeof (used ));
If (! Can (I) return false;
}
Return true;
}

Void solve ()
{
Int FIR = 0, SEC = Tmax * m;
Int ans = 0;
While (FIR <Sec)
{
Int mid = (FIR + Sec)> 1;
If (maxmatch (MID ))
{
Flag = true;
Ans = mid;
SEC = mid;
}
Else
Fir = Mid + 1;
}
If (FLAG) printf ("% d/N", ANS );
Else printf ("-1/N ");
}

Bool NOVA (point & A, point & B, int R)
{
If (sign (a-B). dist ()-R * r)> 0) return false;
For (INT I = 0; I <K; I ++)
{
If (sign (FABS (tree [I]-A) * (B-a)/(a-B ). length ()-Tr [I])> 0) continue;
If (sign (tree [I]-). DOT (B-a) <0 | sign (tree [I]-B ). DOT (a-B) <0) continue;
Return false;
}
Return true;
}

Int main ()
{
Int T;
Scanf ("% d", & T );
While (t --)
{
Tmax = 0;
Flag = false;
Scanf ("% d", & N, & M, & K );
For (INT I = 0; I <n; I ++)
{
Lich [I]. Input ();
Scanf ("% d", & R [I], & T [I]);
If (T [I]> Tmax) tmax = T [I];
}
For (INT I = 0; I <m; I ++) wisp [I]. Input ();
For (INT I = 0; I <K; I ++)
{
Tree [I]. Input ();
Scanf ("% d", & tr [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]);
Solve ();
}
Return 0;
}

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.