You is playing paintball on a, the square eld. A
Number of your opponents is on the eld hiding behind trees
At various positions. Each opponent can re a paintball a
Certain distance in any direction. Can you cross the Eld
Without being hits by a paintball?
Assume that the southwest corner of the Eld are at (0;0)
and the northwest corner at (0,1000).
Input
The input contains several scenario. Each scenario consists
of a line containing n, the number of opponents. A
Line follows for each opponent, containing three real numbers:
The (x; y) location of the opponent and its ring range. The
Opponent can hits you and a paintball if you ever pass within
His ring range.
You must enter the eld somewhere between the southwest
and northwest corner and must leave somewhere between the
Southeast and Northeast Corners.
Output
For each scenario, if your can complete the trip, the output of four real numbers with a digits after the
Decimal place, the coordinates at which you may enter and leave the eld, separated by spaces. If You
Can enter and leave at several places, give the most northerly. If There is no such pair of positions, print
The line: ' Impossible '
Sample Input
3
500 500 499
0 0 999
1000 1000 200
Sample Output
0.00 1000.00 1000.00 800.00
See each enemy in a circle, from the top down to the connected
After writing this question, I feel the structure is cohesive, but not flexible enough.
#include <cstdio>#include<cstring>//#include <vector>//#include <queue>#include <algorithm>#include<math.h>//#define LOCALusing namespacestd;Const intMAXN = ++1;Const DoubleW = +;intX[MAXN], Y[MAXN], R[MAXN];intN;DoubleLeft,right;BOOLIntersectintAintb) {returnsqrt ((X[a]-x[b]) * (X[a]-x[b]) + (Y[a]-y[b]) * (y[a]-y[b)) < r[a]+r[b];}voidCheckintu) { if(X[u] < R[u]) left = min (left, Y[u]-sqrt (r[u]*r[u]-x[u]*X[u])); if(X[u]+r[u] > W) right = min (Right,y[u]-sqrt (R[u]*r[u]-(W-X[U)) * (WX[u])) ) ;}intVIS[MAXN];//top to bottomBOOLDfsintu) { if(Vis[u])return false; Vis[u]=1; if(Y[u] < R[u])return true; for(intv =0; v < n; v++){ if(Intersect (U,V) && Dfs (v))return true; } check (U); return false;}intMain () {#ifdef local freopen ("In.txt","R", stdin);#endif //Local while(~SCANF ("%d",&N)) {BOOLOK =true; memset (Vis,0,sizeof(VIS)); Left= right =W; for(inti =0; I < n; i + +) {scanf ("%d%d%d", x+i,y+i,r+i); } for(inti =0; I < n; i + +) { if(R[i]+y[i]>=w && dfs (i)) {OK =false; Break;} } if(OK) printf ("0.00%.2LF 1000.00%.2lf\n", Left,right); Elseprintf"impossible\n"); } return 0;}
[Dfs]11853-paintball