ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1207. Median on the Plane

I need Help
Posted by Mihran Hovsepyan {2 kurs of <RAU>} 30 Dec 2008 21:47
Now I can got WA 1,2,3,5,6,7 and TLE14

This is my code wich got WA6

# include <iostream>
# include <algorithm>
# include <cmath>
using namespace std;

typedef long double int64;
#define sq(x) x*x

int64 myx0=2000000001,myy0=2000000001;

struct ket
{
    int64 x;
    int64 y;
    int hamar;
} a[10010];

bool operator <(ket e, ket f)
{
    double de=sqrt(sq(e.x-myx0)+sq(e.y-myy0));
    double df=sqrt(sq(f.x-myx0)+sq(f.y-myy0));
    return e.x/de>f.x/df;
}


int main ()
{
    int n,i;
    int ans1,ans2;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i].x>>a[i].y;
        a[i].hamar=i+1;
        if(a[i].y<myy0)
        {
            myx0=a[i].x;
            myy0=a[i].y;
            ans1=a[i].hamar;
        }
        else if(fabs(a[i].y-myy0)<0.00001 && a[i].x<myx0)
        {
            myx0=a[i].x;
            ans1=a[i].hamar;
        }
    }
    swap(a[0],a[ans1-1]);
    sort(a+1,a+n);
    ans2=a[n/2].hamar;
    cout<<ans1<<" "<<ans2;
    return 0;
}

Edited by author 30.12.2008 21:48