Rezultati

Up. imeNalogaJezikRezultatČas oddaje
qubit-2017 Črte C++ 100/100OK 20. apr '17 @ 20:13

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 1528,836 MiB 4,986 s OK
#2 10/10 1528,840 MiB 3,098 s OK
#3 10/10 1528,836 MiB 3,098 s OK
#4 10/10 1528,852 MiB 3,561 s OK
#5 10/10 1528,922 MiB 4,163 s OK
#6 10/10 1528,938 MiB 4,742 s OK
#7 10/10 1528,938 MiB 6,569 s OK
#8 10/10 1528,930 MiB 4,480 s OK
#9 10/10 1528,926 MiB 3,201 s OK
#10 10/10 1528,926 MiB 8,701 s OK

Ocenjevani program (n2.cpp):
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <queue>
 
typedef long long ll;
 
using namespace std;
 
int main(void) {
    cin.tie(nullptr);
    cin.sync_with_stdio(false);
 
    int n;
    cin >> n;
    int* x = new int[n]();
    int* y = new int[n]();
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    map<int,int> d;
    vector<unsigned short> vis(2 * 20000 * 20000 + 1, 0);
    ll pari = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int temp = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
            unsigned short& vtemp = vis[temp];
            if (vtemp < 65534) {
                vtemp++;
                if (vtemp != 1) {
                    pari += ((ll)vtemp - 1LL);
                }
                continue;
            }
            else if (vtemp == 65534) {
                d.insert(make_pair(temp, 65535));
                vtemp++;
                pari += 65534;
            }
            else pari += d[temp]++;
        }
    }
    cout << pari << '\n';
    free(x);
    free(y);
 
    return 0;
}