Rezultati

Up. imeNalogaJezikRezultatČas oddaje
PIN Črte C++ 0/100Prekoračen čas (TLE) 20. apr '17 @ 17:11

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 3,164 MiB 0,004 s OK
#2 10/10 3,238 MiB 0,010 s OK
#3 10/10 3,324 MiB 0,016 s OK
#4 10/10 33,301 MiB 1,307 s OK
#5 0/10 173,508 MiB 10,862 s Prekoračen čas
#6 0/10 3,285 MiB 1,909 s Napačen odgovor
Tvoj izhod:
​1895465784
<<<EOF>>>
Pravilen izhod:
​2591567982003000
<<<EOF>>>
#7 0/10 3,297 MiB 10,478 s Prekoračen čas
#8 0/10 3,070 MiB 10,662 s Prekoračen čas
#9 0/10 4,141 MiB 10,655 s Prekoračen čas
#10 0/10 180,965 MiB 10,909 s Prekoračen čas

Ocenjevani program (line.cpp):
#include <iostream>
#include <vector>
#include <math.h>
#include <map>

using namespace std;

class Point
{
    public:
        int x;
        int y;

        double getDistance(const Point other)
        {
            return sqrt((other.x - this->x) * (other.x - this->x) + (other.y - this->y) * (other.y - this->y));
        }
};


int main()
{    
    int n;

    vector<Point> points;

    Point newPoint;

    cin >> n;
    if(n == 0)
    {
        return 0;
    }
    for(int i = 0; i < n; i++)
    {
        cin >> newPoint.x;
        cin >> newPoint.y;
        
        points.push_back(newPoint);
    }
    //points.push_back(newPoint);

    map<double, int> pairs;

    unsigned int ctr = 0;

    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            double dst = points[i].getDistance(points[j]);

            pairs[dst]++;
            if(pairs[dst] > 1)
            {
                ctr += pairs[dst] - 1;
            }
            //cout << i << ", " << j << " " << dst << " " << pairs[dst] << endl;
        }
    }

    cout << ctr << endl;        






    return 0;
}