Bzoj 3630 jloi2014 mirror channel calculation ry + minimum point cutover set

Source: Internet
Author: User

Given a two-dimensional channel, there are some square and circular parts in the channel (overlapping is allowed), so finding the minimum number of parts deleted can make the light pass through this channel through reflection.

We were scared to speak Japanese when we saw this question! How can I handle this problem ?! How can this problem be solved? How does one comment? Why are there too many other users? I am fully aware of these problems!

I have been delayed for too long on the first and second questions, leading to the absence of time for the third question (the second question has not seen the explosion of multiple groups of data) finally, read all the data, add my birthday, And then modulo + 1 for N, with zero points ..

Write @ vmurder, the only one in the audience that knows the positive solution, writes a coordinate lateral injection of enumeration injection, and kills the component and scores 50 points.

The most terrible thing is that you have the same idea, but it's just that you have made me laugh at the world

This is the smallest point cutover set.

First of all, here is a physical ferma's small theorem. I don't know the specific content, but in short, the question is "water can pass in the past"

So we also want to reflect what is messy! Directly process the circle and square, and intersection and even the edge. The top is the sink under the source, and find the smallest vertex cutover set. This question is cut!

It is really a good question, but my code is a bit scum, I am slow!

#include<stdio.h>#include<stdlib.h>#include<string.h>#include<math.h>#define c(a) memset(a,0,sizeof a)#define M 610#define INF (0x7fffffff)struct abcde{int p,x,y,r,x1,y1,x2,y2;}a[M>>1];struct abcd{int to,f,next;}table[200000];int head[M],tot=1;inline void adddd(int x,int y,int z){table[++tot].to=y;table[tot].f=z;table[tot].next=head[x];head[x]=tot;}inline void addd(int x,int y,int z){adddd(x,y,z),adddd(y,x,0);}inline void add(int x,int y){addd(x<<1|1,y<<1,INF),addd(y<<1|1,x<<1,INF);}inline void swap(int&x,int&y){int z=x;x=y;y=z;}inline double dis(int x1,int y1,int x2,int y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))-(1e-10);}inline int min(int x,int y){return x<y?x:y;}int cx,cy,n,ans,s,t;bool Judge(int x,int y){    int p=a[x].p+a[y].p;    if(p==2)return dis(a[x].x,a[x].y,a[y].x,a[y].y)<=a[x].r+a[y].r?1:0;    if(p==3)    {        if(a[x].p==1)swap(x,y);        if(dis(a[x].x1,a[x].y1,a[y].x,a[y].y)<=a[y].r)return 1;        if(dis(a[x].x1,a[x].y2,a[y].x,a[y].y)<=a[y].r)return 1;        if(dis(a[x].x2,a[x].y1,a[y].x,a[y].y)<=a[y].r)return 1;        if(dis(a[x].x2,a[x].y2,a[y].x,a[y].y)<=a[y].r)return 1;        if(a[x].x2>a[y].x&&a[x].x1<a[y].x)if(abs(a[x].y2-a[y].y)<=a[y].r||abs(a[x].y1-a[y].y)<=a[y].r)return 1;        if(a[x].y2>a[y].y&&a[x].y1<a[y].y)if(abs(a[x].x2-a[y].x)<=a[y].r||abs(a[x].x1-a[y].x)<=a[y].r)return 1;        if(a[x].x1<=a[y].x&&a[x].x2>=a[y].x&&a[x].y1<=a[y].y&&a[x].y2>=a[y].y)return 1;        return 0;    }    if(p==4)    {        if((a[x].x1>=a[y].x1&&a[x].x1<=a[y].x2)||(a[x].x2>=a[y].x1&&a[x].x2<=a[y].x2))        if((a[x].y1>=a[y].y1&&a[x].y1<=a[y].y2)||(a[x].y2>=a[y].y1&&a[x].y2<=a[y].y2))return 1;        if(a[x].x1<=a[y].x1&&a[y].x2<=a[x].x2&&a[y].y1<=a[x].y1&&a[x].y2<=a[y].y2)return 1;        swap(x,y);        if((a[x].x1>=a[y].x1&&a[x].x1<=a[y].x2)||(a[x].x2>=a[y].x1&&a[x].x2<=a[y].x2))        if((a[x].y1>=a[y].y1&&a[x].y1<=a[y].y2)||(a[x].y2>=a[y].y1&&a[x].y2<=a[y].y2))return 1;        if(a[x].x1<=a[y].x1&&a[y].x2<=a[x].x2&&a[y].y1<=a[x].y1&&a[x].y2<=a[y].y2)return 1;        return 0;    }}int q[65540],f[M],d[M];unsigned short r,h;bool bfs(){    int i;    memset(d,0,sizeof d);    h=r;q[++r]=s;d[s]=1;    while(h!=r)    {        h++;        for(i=head[q[h]];i;i=table[i].next)        if(table[i].f&&!d[table[i].to])        {            q[++r]=table[i].to;            d[table[i].to]=d[q[h]]+1;            if(table[i].to==t)return 1;        }    }    return 0;}int dinic(int x,int flow){    int temp=flow,k,i;    if(x==t)return flow;    for(i=head[x];i;i=table[i].next)    if(table[i].f&&temp&&d[table[i].to]==d[x]+1)    {        k=dinic(table[i].to,min(temp,table[i].f) );        if(!k)d[table[i].to]=0;        table[i].f-=k;        table[i^1].f+=k;        temp-=k;    }    return flow-temp;}int main(){    int i,j,flow;    scanf("%d%d%d",&cx,&cy,&n);    s=1;t=n+1<<1;    a[0].p=2;a[0].x1=0;a[0].y1=cy;a[0].x2=cx;a[0].y2=cy;    a[n+1].p=2;a[n+1].x1=0;a[n+1].y1=0;a[n+1].x2=cx;a[n+1].y2=0;    for(i=1;i<=n;i++)    {        scanf("%d",&a[i].p);        if(a[i].p==1)scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].r);        else scanf("%d%d%d%d",&a[i].x1,&a[i].y1,&a[i].x2,&a[i].y2);        for(j=0;j<i;j++)if(Judge(i,j))add(i,j);    }    for(j=1;j<i;j++)if(Judge(j,i))add(j,i);    for(i=1;i<=n;i++)adddd(i<<1,i<<1|1,1),adddd(i<<1|1,i<<1,1);    while( bfs() )        while( flow=dinic(s,INF) )            ans+=flow;    printf("%d",ans);} 


Bzoj 3630 jloi2014 mirror channel calculation ry + minimum point cutover set

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.