HUD 4007 [Scan line] [order]

Source: Internet
Author: User

/*Dalian Warm-up B do not bow, do not give up, do not be discouraged, do not panic test instructions: Coordinate plane to a lot of points, put a side length of r and axis parallel to the square, asked the number of points in the square inside. Idea: Sort by x, then make sure X is in the legal range followed by Y to scan the line. */#include<bits/stdc++.h>using namespacestd;BOOLvis[1050];structst{voidRead () {scanf ("%d%d",&x,&y); }    intx, y;}; St jilu[1050];BOOLCMP (St A,st b) {returna.x<b.x;}BOOLCMP2 (St A,st b) {returna.y<b.y;}intMain () {intN,r;  while(SCANF ("%d%d", &n,&r)! =EOF) {        intans=1; memset (Vis,0,sizeof(VIS));  for(intI=0; i<n;i++) Jilu[i].read (); Sort (Jilu,jilu+n,cmp); intEd=0;  for(intI=0; i<n;i++){             while(ed<n&&jilu[ed].x<=jilu[i].x+r) ed++; Sort (Jilu+i,jilu+ED,CMP2); intnum=1; intst=i;  for(intj=i+1; j<ed;j++){                 while(jilu[st].y<jilu[j].y-r) st++; Ans=max (ans,j-st+1); } sort (Jilu+i,jilu+ed,cmp); } printf ("%d\n", ans); }}

HUD 4007 [Scan line] [order]

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.