Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
这题我用map写为什么TLE。。。#include <iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<map> using namespace std; const int mm=1005; struct point { double x,y; point() {} point(double _x,double _y) { x=_x,y=_y; } bool operator<(const point &a)const { if(x==a.x) return y<a.y; return x<a.x; } }; map<point,int>mymap; bool check(point a,point c) { point b((c.x+a.x+c.y-a.y)/2,(c.y+a.y+a.x-c.x)/2), d((c.x+a.x+a.y-c.y)/2,(c.y+a.y+c.x-a.x)/2); if(mymap[b]==1&&mymap[d]==1) return 1; return 0; } int main() { int n; point data[1005]; while(~scanf("%d",&n),n) { mymap.clear(); for(int i=0; i<n; i++) scanf("%lf%lf",&data[i].x,&data[i].y),mymap[data[i]]=1; int ans=0; for(int i=0; i<n; i++) for(int j=i+1; j<n; j++) if(check(data[i],data[j])) ans++; printf("%d\n",ans/2); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator