Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 415,297 MiB 0,309 s OK
#2 10/10 415,414 MiB 1,447 s OK
#3 10/10 415,457 MiB 0,741 s OK
#4 10/10 430,445 MiB 1,414 s OK
#5 0/10 843,211 MiB 10,825 s Prekoračen čas
#6 10/10 415,469 MiB 1,373 s OK
#7 10/10 415,477 MiB 1,374 s OK
#8 10/10 415,543 MiB 1,782 s OK
#9 10/10 415,984 MiB 5,229 s OK
#10 0/10 740,051 MiB 11,061 s Prekoračen čas

Ocenjevani program (main.cpp):
#include <bits/stdc++.h>

using namespace std;

const int N = 12000;
const int DIST = 2 * 20000*20000;

int n;
int x[N], y[N];

unordered_map<int, int> cnt;

int sqr(int x) {
    return x*x;
}

using llong = long long;

llong choose(llong n) {
    return (n*(n-1))/2;
}

int main() {
    cin>>n;

    for(int i=0;i<n;i++) {
        cin>>x[i]>>y[i];
    }

    cnt.reserve(DIST / 16);

    for(int i=0;i<n;i++) {
        for(int j=i+1;j<n;j++) {
            if(i!=j) {
                int dist = sqr(x[i] - x[j]) + sqr(y[i] - y[j]);
                cnt[dist]++;
            }
        }
    }

    llong res = 0;

    for(const auto& kv : cnt) {
        if(kv.second > 1)
            res += choose(kv.second);
    }

    cout << res;

    return 0;
}