hdu1337 learned and Yin-yang family

Source: Internet
Author: User

Address: http://acm.uestc.edu.cn/#/problem/show/1337

Ideas:

learned and Yin-yang familyTime limit:3000/4000ms (java/others) Memory limit:262144/262144kb (java/others)SubmitStatus

"Filth" is from the different World "Evil Wild" appeared, the monster that endangers the earth. The "Yin and Yang division" has been fighting filth for many years now.

Teenager juvenile learned had to become able to hashi in addition to all the most filthy the strongest yin and Yang division, but since the encounter "The Tragedy of the moon", he gave up to become a yin and Yang division.

At this time, in front of such learned, there is a maiden, the girl from Kyoto, the same to Hashi in addition to pollution as ideal, and show the amazing strength ...

......

One day, learned once again encounter filth endanger the world, learned nature determined to take action, to remove these filth!

The most powerful weapon of the yin and Yang division is derived from his own charms to ignite the spirits in the air, thus causing harm to those filth.

These elves as long as the coordinates can form a parallelogram words, can release the learned of the strongest trick-extermination!

Now suppose the battlefield is a two-dimensional plane, so how many formations can make the learned release this extermination?

We think that this formation is different as long as the parallelogram has a different coordinate of the point.

Of course, the area of parallelogram must be positive.

Input

The first line contains an integerNN (1≤n≤    1≤n≤2000)-Indicates the number of sprites on the plane

The nextNn rows, each row contains two integers(XI, Yi)   (0 ≤ Xi y I ≤ 1000000000) (xi, Yi) (0≤xi, yi≤1000000000)-represents the coordinates of the sprite

Output

Outputs an integer that represents the answer

Sample Input and output
Sample Input Sample Output
40 11 01) 12 0
1
Ideas:

Can make up parallelogram is the midpoint of two segments equal (not in the same line)

So the midpoint is calculated for all the segments that make up all the points. (ask for a point before the midpoint, it's scary, because there are multiple points of overlap

Then judge the midpoint equal good, sweep it again, but because there are more points collinear what, so also need to record two additional information, and x-axis intersection and K+B value (I use Y=kx+b to represent straight line, because there is a vertical situation, so save k+b),,,,,,,,,,,,,,,,,,,

Code:

1#include <iostream>2#include <algorithm>3#include <cstdio>4#include <cmath>5#include <cstring>6#include <queue>7#include <stack>8#include <map>9#include <Set>Ten#include <vector> One#include <cstdlib> A#include <string> -#include <bitset> -#include <vector> the #definePI ACOs ((double)-1) - #defineE exp (double (1)) - #defineINF 100000000 - #defineEPS 1e-9 + using namespacestd; -pair<int,int>a[2020]; + intuse[2020]; A structP at { -     DoubleX,y,vx,vy,dis; -}p[2020*2020]; -  - BOOLCMP1 (pair<int,int> tx,pair<int,int>ty) - { in     if(Tx.first = =Ty.first) -         returntx.second<Ty.second; to     returnTx.first <Ty.first; + } - BOOLcmp2 (P tx,p ty) the { *     if(tx.x = =ty.x) $         returntx.y<ty.y;Panax Notoginseng     returntx.x<ty.x; - } the intMainvoid) + { A     intN,num,cnt=0; theCin>>N; +memset (use,0,sizeof(use)); -      for(intI=1; i<=n;i++) $scanf"%d%d",&a[i].first,&a[i].second); $Sort (A +1, a+n+1); -      for(intI=1; i<n;i++) -         if(a[i].first==a[i+1].first && a[i].second==a[i+1].second) theuse[i]=1; -num=0;Wuyi      for(intI=1; i<n;i++) the          for(intj=i+1; J<=n &&!use[i];j++) -             if(!Use[j]) Wu             { -                 Doublek,b; Aboutp[++num].x= (A[i].first+a[j].first)/2.0;//Öðµã $p[num].y= (A[i].second+a[j].second)/2.0; -                 if(a[j].first-a[i].first==0) -                 { -p[num].vy=772237; Ap[num].vx=A[i].first; +p[num].dis=2223333; the                     Continue; -                 } $k= (A[j].second-a[i].second) *1.0/(a[j].first-A[i].first); theb=a[i].second-k*A[i].first; thep[num].vy=b; thep[num].vx=-b/K; thep[num].dis=k+b; -             } inSort (p+1, p+num+1, CMP2); the      for(intI=1; i<num;i++) the          for(intj=i+1ABS (p[j].x-p[i].x) <eps && abs (P[I].Y-P[J].Y) <eps && j<=num;j++) About         if(! (ABS (P[I].VY-P[J].VY) <eps && ABS (P[i].dis-p[j].dis) <EPS)) thecnt++; theprintf"%d\n", CNT); the     return 0; +}
View Code

hdu1337 learned and Yin-yang family

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.