Language: C++

#include <climits>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

#define MAX_N 100000

class Node
{
    public:
        int x, y, index, cost = INT_MAX;;
        bool used = false;
};

int n;
int A[MAX_N][MAX_N] = {};
Node *nodes = new Node[MAX_N];

int prim()
{
    int i, u, v, minv, sum = 0;
    nodes[0].cost = 0;
    while (true) {
        u = -1; minv = INT_MAX;
        for (i = 0; i < n; i++) {
            if (nodes[i].cost < minv && !nodes[i].used) {
                u    = i;
                minv = nodes[i].cost;
            }
        }
        if (-1 == u) break;
        nodes[u].used = true;
        sum += nodes[u].cost;
        for (v = 0; v < n; v++) {
            if (!nodes[v].used && A[u][v] != 0) {
                nodes[v].cost = A[u][v] < nodes[v].cost ? A[u][v] : nodes[v].cost;
            }
        }
    }
    return sum;
}

bool xsort(Node a, Node b)
{
    if (a.x < b.x) return true;
    else return false;
}

bool ysort(Node a, Node b)
{
    if (a.y < b.y) return true;
    else return false;
}
void build_table()
{
    Node *xsorted = new Node[n];
    Node *ysorted = new Node[n];
    memcpy(xsorted, nodes, sizeof(Node) * n);
    memcpy(ysorted, nodes, sizeof(Node) * n);
    sort(xsorted, xsorted + n, xsort);
    sort(ysorted, ysorted + n, ysort);
/*
    cout << "xsorted:" << endl;
    for (int i = 0; i < n; i++) {
        cout << xsorted[i].x << " " << xsorted[i].y << endl;
    }
    cout << "ysorted:" << endl;
    for (int i = 0; i < n; i++) {
        cout << ysorted[i].x << " " << ysorted[i].y << endl;
    }
*/
    for (int i = 1; i < n - 1; i++) {
        A[xsorted[i].index][xsorted[i - 1].index] = A[xsorted[i].index][xsorted[i - 1].index] == 0 ? xsorted[i].x - xsorted[i - 1].x : min(xsorted[i].x - xsorted[i - 1].x, A[xsorted[i].index][xsorted[i - 1].index]);
        A[xsorted[i - 1].index][xsorted[i].index] = A[xsorted[i - 1].index][xsorted[i].index] == 0 ? xsorted[i].x - xsorted[i - 1].x : min(xsorted[i].x - xsorted[i - 1].x, A[xsorted[i - 1].index][xsorted[i].index]);
        A[xsorted[i + 1].index][xsorted[i].index] = A[xsorted[i + 1].index][xsorted[i].index] == 0 ? xsorted[i + 1].x - xsorted[i].x : min(xsorted[i + 1].x - xsorted[i].x, A[xsorted[i + 1].index][xsorted[i].index]);
        A[xsorted[i].index][xsorted[i + 1].index] = A[xsorted[i].index][xsorted[i + 1].index] == 0 ? xsorted[i + 1].x - xsorted[i].x : min(xsorted[i + 1].x - xsorted[i].x, A[xsorted[i].index][xsorted[i + 1].index]);
        A[ysorted[i].index][ysorted[i - 1].index] = A[ysorted[i].index][ysorted[i - 1].index] == 0 ? ysorted[i].y - ysorted[i - 1].y : min(ysorted[i].y - ysorted[i - 1].y, A[ysorted[i].index][ysorted[i - 1].index]);
        A[ysorted[i - 1].index][ysorted[i].index] = A[ysorted[i - 1].index][ysorted[i].index] == 0 ? ysorted[i].y - ysorted[i - 1].y : min(ysorted[i].y - ysorted[i - 1].y, A[ysorted[i - 1].index][ysorted[i].index]);
        A[ysorted[i + 1].index][ysorted[i].index] = A[ysorted[i + 1].index][ysorted[i].index] == 0 ? ysorted[i + 1].y - ysorted[i].y : min(ysorted[i + 1].y - ysorted[i].y, A[ysorted[i + 1].index][ysorted[i].index]);
        A[ysorted[i].index][ysorted[i + 1].index] = A[ysorted[i].index][ysorted[i + 1].index] == 0 ? ysorted[i + 1].y - ysorted[i].y : min(ysorted[i + 1].y - ysorted[i].y, A[ysorted[i].index][ysorted[i + 1].index]);
    }
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) {
        nodes[i].index = i;
        cin >> nodes[i].x >> nodes[i].y;
    }
    build_table();
/*    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cout << " " << A[i][j];
      }
      cout << endl;
    }
*/
    cout << prim() << endl;
    return 0;
}

Compiler output:
/tmp/ccIgo44U.o: in function `prim()':
a.cc:(.text+0xe): relocation truncated to fit: R_X86_64_PC32 against symbol `nodes' defined in .bss section in /tmp/ccIgo44U.o
a.cc:(.text+0x33): relocation truncated to fit: R_X86_64_PC32 against symbol `nodes' defined in .bss section in /tmp/ccIgo44U.o
a.cc:(.text+0x59): relocation truncated to fit: R_X86_64_PC32 against symbol `nodes' defined in .bss section in /tmp/ccIgo44U.o
a.cc:(.text+0x88): relocation truncated to fit: R_X86_64_PC32 against symbol `nodes' defined in .bss section in /tmp/ccIgo44U.o
a.cc:(.text+0xc9): relocation truncated to fit: R_X86_64_PC32 against symbol `nodes' defined in .bss section in /tmp/ccIgo44U.o
a.cc:(.text+0xeb): relocation truncated to fit: R_X86_64_PC32 against symbol `nodes' defined in .bss section in /tmp/ccIgo44U.o
a.cc:(.text+0x11b): relocation truncated to fit: R_X86_64_PC32 against symbol `nodes' defined in .bss section in /tmp/ccIgo44U.o
a.cc:(.text+0x19e): relocation truncated to fit: R_X86_64_PC32 against symbol `nodes' defined in .bss section in /tmp/ccIgo44U.o
a.cc:(.text+0x1ec): relocation truncated to fit: R_X86_64_PC32 against symbol `nodes' defined in .bss section in /tmp/ccIgo44U.o
a.cc:(.text+0x20d): relocation truncated to fit: R_X86_64_PC32 against symbol `nodes' defined in .bss section in /tmp/ccIgo44U.o
/tmp/ccIgo44U.o: in function `build_table()':
a.cc:(.text+0x383): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status