Submission #28202

# Submission time Handle Problem Language Result Execution time Memory
28202 2017-07-15T15:20:20 Z psint Ideal city (IOI12_city) C++14
Compilation error
0 ms 0 KB
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
#define MAXN 100010

int n;
const int MOD = 1000000000;

int cnt;
int W[MAXN], N[MAXN];
queue<int> Q;
set<int> E[MAXN];
map<pair<int,int>, int> M;

pair<int,int> dfs(int node, int src) {
    int total = W[node], ans = 0;
    for (auto next : E[node]) if (src != next) {
        pair<int,int> result = dfs(next, node);
        ans = (ans + result.first) % MOD;
        ans = (ans + ((long long) result.second * (long long) (n - result.second)) % MOD) % MOD;
        total += result.second;
    }
    return { ans, total };
}

int findDist(vector<int> &X, vector<int> &Y) {
    cnt = 0; M.clear();
    for (int i = 0; i < MAXN; i ++) { E[i].clear(); W[i] = 0; N[i] = -1; }

    for (int i = 0; i < n; i ++) M[{ X[i], Y[i] }] = i+1;
    for (int i = 0; i < n; i ++) if (N[i] == -1) {
        Q.push(i);
        while (!Q.empty()) {
            int node = Q.front(); Q.pop();
            if (N[node] != -1) continue;
            N[node] = cnt;
            W[cnt] ++;
            for (int diff = -1; diff <= 1; diff += 2) {
                int next = M[{ X[node], Y[node] + diff }];
                if (next != 0) Q.push(next-1);
            }
        }
        cnt ++;
    }

    for (int i = 0; i < n; i ++) for (int diff = -1; diff <= 1; diff += 2) {
        int j = M[{ X[i] + diff, Y[i] }];
        if (j != 0) E[N[i]].insert(N[j-1]);
    }

    return dfs(0, -1).first;
}

Compilation message

/tmp/ccZnvTdf.o: In function `main':
grader.cpp:(.text.startup+0xf1): undefined reference to `DistanceSum(int, int*, int*)'
collect2: error: ld returned 1 exit status