The main idea: there are some lich and some elves in the plane, and some trees will stop the lich's sight. Each lich has a radius of attack, if a elf within the attack radius of the Lich, two points between the lines of no trees block, then the Lich can kill the elves. Each lich has a skill CD. Ask how long it takes to get the elves out of the way.
Idea: See the range of Knowledge Algorithm series. It is obvious that the two points + maximum flow. Two minutes in the shortest time, in this time, each lich can send strokes TIME/CD + 1 times. So every time the map is built from S to the number of times each lich can output the flow of the edge. Each lich to the elf to be able to attack the edge, and then each elf to the T edge. Each time you judge whether Max_flow is equal to the number of elves.
CODE:
#include <queue> #include <cmath> #include <vector> #include <cstdio> #include <cstring># Include <iostream> #include <algorithm> #define MAX 510#define maxe 1000000#define INF 0x3f3f3f3f#define S 0# Define T (MAX-1) using namespace std; #define MIN (b) ((a) < (a):(B)) struct point{int x, y;} Pos[max];struct complex{point p;int r;void Read () {scanf ("%d%d%d", &p.x,&p.y,&r);}} src[max],tree[max];vector<int> can[max];int _time[max];int cnt,_cnt,trees;inline double Calc (const point & P1,const Point &p2) {return sqrt ((p1.x-p2.x) * (p1.x-p2.x) + (P1.Y-P2.Y) * (P1.Y-P2.Y));} Inline double Getarea (const point &p1,const point &p2,const point &p3) {double L1 = Calc (p1,p2), L2 = Calc (p2,p3 ), L3 = Calc (P3,P1);d ouble p = (L1 + L2 + L3)/2;return sqrt (p * (P-L1) * (P-L2) * (P-L3));} inline bool InRange (const Complex &tree,const point &p1,const point &p2) {Double area = Getarea (P1,P2,TREE.P) * 2;double Dis = Area/calc (P1,P2); return dis <= TREE.R;} int head[max],total;int next[maxe],aim[maxe],flow[maxe];inline void Add (int x,int y,int f) {next[++total] = head[x];aim[ Total] = Y;flow[total] = f;head[x] = total;} inline void Insert (int x,int y,int f) {Add (x,y,f); ADD (y,x,0);} inline void buildgraph (int ans) {memset (head,0,sizeof (head)); total = 1;for (int i = 1; I <= cnt; ++i) {Insert (S,i,ans/_ Time[i] + 1); for (Vector<int>::iterator it = Can[i].begin (); It! = Can[i].end (); ++it) Insert (i,cnt + *it,1);} for (int i = 1; I <= _cnt; ++i) Insert (cnt + i,t,1);} int deep[max];inline bool BFS () {static queue<int> Q;while (!q.empty ()) Q.pop () memset (deep,0,sizeof (deep));d eep [s] = 1;q.push (s), while (!q.empty ()) {int x = Q.front (), Q.pop (); for (int i = head[x]; i; i = Next[i]) if (!deep[aim[i]] & & Flow[i]) {Deep[aim[i]] = deep[x] + 1;q.push (Aim[i]), if (aim[i] = = T) return true;}} return false;} int dinic (int x,int f) {if (x = = T) return F;int temp = f;for (int i = head[x]; i; i = Next[i]) if (temp &Amp;& Deep[aim[i]] = = Deep[x] + 1 && flow[i]) {int away = Dinic (Aim[i],min (flow[i],temp)); if (!away) deep[aim[i] ] = 0;flow[i]-= away;flow[i^1] + = away;temp-= away;} return f-temp;} int main () {cin >> cnt >> _cnt >> trees;for (int i = 1; I <= cnt; ++i) {src[i]. Read (); scanf ("%d", &_time[i]);} for (int i = 1; I <= _cnt; ++i) scanf ("%d%d", &pos[i].x,&pos[i].y), for (int i = 1; i <= trees; ++i) tree[i]. Read (); for (int i = 1; I <= cnt, ++i) for (int j = 1; j <= _cnt; ++j) if (Calc (Src[i].p,pos[j]) <= SRC[I].R) {BOOL FLA g = true;for (int k = 1; k <= trees; ++k) if (InRange (Tree[k],src[i].p,pos[j])) flag = FALSE;IF (flag) Can[i].push_back (j); int L = 0,r = 10000000,ans = -1;while (l <= r) {int mid = (L + r) >> 1; Buildgraph (mid), int max_flow = 0;while (BFS ()) Max_flow + = Dinic (S,inf); if (Max_flow = = _cnt) r = Mid-1,ans = Mid;elsel = mi D + 1;} cout << ans << endl;return 0;}
Bzoj 1822 Jsoi Frozen Nova frozen wave two points + network flow