"Analog" HDU 5762 Teacher Bo

Source: Internet
Author: User

Topic Links:

http://acm.hdu.edu.cn/showproblem.php?pid=5762

Main Topic :

Give n points, coordinate range 0~m (n,m<=105), to find whether there are 2 points to meet Huffman distance equal.

Topic Ideas:

  Simulation

 At first glance N2 Absolute T, but under the small thought found that the coordinate range is only 105, then Huffman distance is the most 2x105 species, so when the cycle beyond this range will certainly find the solution (drawer principle).

1 //2 //by Coolxxx3 //4#include <iostream>5#include <algorithm>6#include <string>7#include <iomanip>8#include <memory.h>9#include <time.h>Ten#include <stdio.h> One#include <stdlib.h> A#include <string.h> - //#include <stdbool.h> -#include <math.h> the #defineMin (a) < (b) ( A):(B)) - #defineMax (a) (a) > (b)? ( A):(B)) - #defineABS (a) ((a) >0? ( A):(-(a))) - #defineLowbit (a) (a& (a)) + #defineSqr (a) ((a) * (a)) - #defineSwap (a) (a) ^= (b), (b) ^= (a), (a) ^= (b)) + #defineEPS (1E-8) A #defineJ 10000000 at #defineMAX 0x7f7f7f7f - #definePI 3.1415926535897 - #defineN 100004 - using namespacestd; -typedefLong LongLL; - intCas,cass; in intN,m,lll,ans; - structXXX to { +     intx, y; - }a[n]; the BOOLu[n<<1]; * voidWork () $ {Panax Notoginseng     inti,j,x; -      for(i=1; i<=n;i++) the     { +          for(j=i+1; j<=n;j++) A         { theX=abs (a[i].x-a[j].x) +abs (a[i].y-a[j].y); +             if(U[x]) -             { $Puts"YES"); $                 return; -             } -u[x]=1; the         } -     }WuyiPuts"NO"); the } - intMain () Wu { - #ifndef Online_judge About //freopen ("1.txt", "R", stdin); $ //freopen ("2.txt", "w", stdout); -     #endif -     inti,j,x; -      for(SCANF ("%d", &cas); cas;cas--) A //for (scanf ("%d", &cas), cass=1;cass<=cas;cass++) + //while (~scanf ("%s", s)) the //while (~scanf ("%d", &n)) -     { $memset (U,0,sizeof(U)); thescanf"%d%d",&n,&m); the          for(i=1; i<=n;i++) thescanf"%d%d",&a[i].x,&a[i].y); the Work (); -     } in     return 0; the } the /* About // the  the // the */
View Code

"Analog" HDU 5762 Teacher Bo

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.