UPCOJ2985 Gopher (two-point match)

Source: Internet
Author: User
Tags gopher

This problem is our weak school freshman race of the anti-AK problem ...

I was looking at him in less than 1.5 hours to finish the other questions.

But I didn't learn to match the two points.

Then the various structures of the sort ...

It's been 3 hours or a defeat.

So I learned a bit, and it was easy.

Test instructions is to give you n a mouse m-hole, and give you the coordinates and the speed of the mouse and the latest time

By these distances, each mouse will be able to enter in the specified time for each hole.

And then just ... All right

/************************************************author:d evilcreated TIME:2016/4/8 23:53:26****************** ****************************** */#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<vector>#include<queue>#include<Set>#include<map>#include<string>#include<cmath>#include<stdlib.h>using namespacestd;Doublex1[ the],x2[ the],yy[ the],y2[ the];BOOLvis[ the];intn,m,s,v,linker[ the];vector<int>eg[ the];intDfsintu) {     for(intI=0; I<eg[u].size (); i++)    {        intto=Eg[u][i]; if(!Vis[to]) {Vis[to]=1; if(linker[to]==-1||DFS (Linker[to])) {Linker[to]=T; return 1; }        }    }    return 0;}intMain () {//freopen ("In.txt", "R", stdin);     while(~SCANF ("%d%d%d%d",&n,&m,&s,&v)) { for(intI=0; i<n; i++) eg[i].clear (); MEMSET (linker,-1,sizeof(linker));  for(intI=0; i<n; i++) scanf ("%LF%LF",&x1[i],&Yy[i]);  for(intI=0; i<m; i++) scanf ("%LF%LF",&x2[i],&Y2[i]); V=v*s*v*s;  for(intI=0; i<n; i++)        {             for(intj=0; j<m; J + +)            {                DoubleP= (X1[i]-x2[j]) * (X1[i]-x2[j]) + (Yy[i]-y2[j]) * (yy[i]-Y2[j]); if(p<=v) eg[i].push_back (j); }        }        intans=0;  for(intI=0; i<n; i++) {memset (Vis,0,sizeof(VIS)); Ans+=DFS (i); } printf ("%d\n", N-ans); }    return 0;}

UPCOJ2985 Gopher (two-point match)

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.