Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这题我用map写为什么TLE。。。

Posted by 6363817 at 2013-06-03 14:51:45 on Problem 2002
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator