gym-101915j The Volcano eruption computational geometry

Source: Internet
Author: User

Surface

Test instructions: give you a matrix, and then there are a lot of circles, these circles may intersect, one or a few lead to this rectangle is split open, that is, from the bottom edge to the upper edge, the lines are blocked by these circles, each pile of circles as a hindrance, ask a total of several obstacles

The problem: It looks so hard to do ah!~!, how do I know a bunch of circles will be the matrix of a cross-section of the local area are accounted for

Eh then suddenly found that the intersection of the 2 circle, is not able to connect the edge,

Then from the sub-chart for each unicom, is not the leftmost circle on a bit more than the left side of the rectangle, while the right is also separated!

So the map (the actual figure does not have to be built out), DFS a bit on the line

Pay attention to the problem of precision, all of the size-related final with EPS

1#include <bits/stdc++.h>2 using namespacestd;3 #defineN 10054 #defineEPS 1e-65 DoubleW,L,X[N],Y[N],R[N],LL,RR;6 intcnt,t,n,vis[n],ok=1;7 DoubleSqrDoublex) {returnx*x;}8 intCheckintAintb)9 {Ten     return((Sqr (X[a]-x[b]) +SQR (Y[a]-y[b]) &LT;SQR (r[a]+r[b]+EPS)); One } A voidDfsintu) - { -     if(Vis[u])return ; thevis[u]=1; -     if(x[u]+r[u]>=w) ok=0; -      for(intv=0; v<n;v++) -     { +         if(V==u)Continue; -         if(!vis[v] &&Check (u,v)) Dfs (v); +     } A     return ; at } - intMain () - { -scanf"%d",&T); -      while(t--) -     { inscanf"%D%LF%LF",&n,&w,&l); -Cnt=0; tomemset (Vis,0,sizeof(Vis)); +          for(intI=1; i<=n;i++) scanf ("%LF%LF%LF",&x[i],&y[i],&r[i]); -          for(intI=1; i<=n;i++) the             if(x[i]-r[i]<=EPS) *             { $ok=1;Panax Notoginseng                 if(!Vis[i]) DFS (i); -                 if(ok==0) cnt++; the                  +             } Aprintf"%d\n", CNT);  the     } +}

gym-101915j The Volcano eruption computational geometry

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.