"Calculate geometry" "Dichotomy answer" "Max Flow" bzoj1822 [Jsoi2010]frozen Nova frozen Wave

Source: Internet
Author: User

Use the Triangle area to calculate points to the distance of the line and so on ... In fact, the situation of tangency is feasible ... The rest is just like a SDOI2015.

#include <cstdio> #include <cmath> #include <algorithm> #include <cstring> #include <queue >using namespace std; #define N 201#define EPS 0.000001#define INF 2147483647struct point{int x, y;} Jl[n];typedef point vector;typedef double db; Vector operator-(point A,point B) {return (Vector) {a.x-b.x,a.y-b.y};} int Cross (Vector A,vector b) {return a.x*b.y-a.y*b.x;} int sqr (int x) {return x*x;} DB Dis (point A,point b) {return sqrt ((db) (SQR (a.x-b.x) +SQR (A.Y-B.Y)));} struct wy{point p; int r,t;} Wy[n];struct shu{point p; int r;} Shu[n];int Abs (int x) {return x<0? ( -X): ×;}  BOOL Can[n][n];int n,m,k;bool can_attack (WY a,point b) {if (db) A.r-dis (a.p,b) <eps) return 0;for (int i=1;i<=k;++i) if (db) Abs (Cross (a.p-b,shu[i].p-b))/dis (a.p,b)-(db) shu[i].r<-eps) return 0;return 1;} BOOL must_be_attacked (int x) {for (int i=1;i<=n;++i) if (Can[i][x]) return 1;return 0;} Queue<int>q;int nn,t,s;int v[2*n* (n+1)],en,first[n*2+3],next[2*n* (n+1)],cap[2*n* (N+1)];int d[N*2+3],cur[N*2 +3];voID addedge (int u,int v,int Cap) {v[en]=v; cap[en]=cap; next[en]=first[u]; first[u]=en++;v[en]=u; cap[en]=0; next[en]= FIRST[V]; first[v]=en++;}  BOOL BFs () {memset (d,-1,sizeof (int) * (nn+1));d [s]=0; Q.push (S); while (!q.empty ()) {int U=q.front (); Q.pop ();        for (int i=first[u];i!=-1;i=next[i]) if (cap[i]&&d[v[i]]==-1) {d[v[i]]=d[u]+1;      Q.push (V[i]); }}return d[t]!=-1;} int dfs (int u,int a) {if (u==t| | (!a))    return a;int flow=0,f;for (int i=first[u];i!=-1;i=next[i]) if (d[v[i]]==d[u]+1&& (F=dfs (v[i],min))))      {cap[i]-=f;      Cap[i^1]+=f;      Flow+=f;      A-=f;    if (!a) break; }if (! flow) D[u]=-1;return flow;}  int Maxflow () {int flow=0,tmp;while (BFS ()) {memcpy (cur,first,sizeof (int) * (nn+1));  while (Tmp=dfs (S,inf)) flow+=tmp; }return Flow;} BOOL Check (int Lim) {memset (first,-1,sizeof (int) * (nn+1)), en=0;for (int i=1;i<=n;++i) Addedge (S,1+i, (! Lim)? 1: (lim/wy[i].t+1)), for (int i=1;i<=m;++i) Addedge (1+n+i,t,1), for (int i=1;i<=n;++i) for (int j=1;j<=m;++j) if (Can[i][j]) Addedge (1+i,1+n+j,inf); return Maxflow () ==m?1:0;} int main () {scanf ("%d%d%d", &n,&m,&k), for (int i=1;i<=n;++i) scanf ("%d%d%d%d", &wy[i].p.x,&wy[ I].P.Y,&AMP;WY[I].R,&AMP;WY[I].T), for (int i=1;i<=m;++i) scanf ("%d%d", &jl[i].x,&jl[i].y), and for (int i=1;i <=k;++i) scanf ("%d%d%d", &AMP;SHU[I].P.X,&AMP;SHU[I].P.Y,&AMP;SHU[I].R); for (int. i=1;i<=n;++i) for (int j=1;j &LT;=M;++J) Can[i][j]=can_attack (Wy[i],jl[j]); for (int j=1;j<=m;++j) if (! Must_be_attacked (j)) {puts ("-1"); return 0;} t=nn=n+m+2;  S=1;int L=0,r=4000000;while (r>l) {int mid= (l+r>>1);  if (check (mid)) R=mid;  else l=mid+1; }printf ("%d\n", l); return 0;}

Compute geometry, dichotomy answer, max flow bzoj1822 [Jsoi2010]frozen Nova freeze Wave

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.