| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1072424 | Zicrus | Towns (IOI15_towns) | C++17 | 19 ms | 1112 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "towns.h"
using namespace std;
typedef long long ll;
unordered_map<ll, int> cache;
int getDist(int a, int b) {
    if (a == b) return 0;
    if (a < b) swap(a, b);
    ll hash = ((ll)a << 31) | b;
    if (cache.count(hash)) return cache[hash];
    return cache[hash] = getDistance(a, b);
}
int hubDistance(int n, int sub) {
    cache.clear();
    ll a = 0, b = 0;
    ll mxDist = 0;
    for (int i = 1; i < n; i++) {
        ll val = getDist(0, i);
        if (val > mxDist) {
            mxDist = val;
            a = i;
        }
    }
    mxDist = 0;
    for (int i = 0; i < n; i++) {
        ll val = getDist(a, i);
        if (val > mxDist) {
            mxDist = val;
            b = i;
        }
    }
    ll res = 1ll << 62ll;
    for (int i = 0; i < n; i++) {
        if (i == a || i == b) continue;
        ll distA = getDist(i, a);
        ll distB = getDist(i, b);
        ll nw = (distA + distB - mxDist) / 2;
        distA -= nw;
        distB -= nw;
        ll val = max(distA, distB);
        res = min(res, val);
    }
    vector<int> deg(mxDist+1);
    deg.front() = deg.back() = 1;
    for (int i = 0; i < n; i++) {
        if (i == a || i == b) continue;
        ll distA = getDist(i, a);
        ll distB = getDist(i, b);
        ll nw = (distA + distB - mxDist) / 2;
        distA -= nw;
        deg[distA]++;
    }
    unordered_set<ll> hubs;
    for (int i = 0; i < n; i++) {
        int d = max(i, (int)mxDist-i);
        if (d == res) hubs.insert(i);
    }
    ll sum = 0;
    for (int i = 0; i <= mxDist; i++) {
        if (sum > n/2 && hubs.count(i)) hubs.erase(i);
        sum += deg[i];
    }
    sum = 0;
    for (int i = mxDist; i >= 0; i--) {
        if (sum > n/2 && hubs.count(i)) hubs.erase(i);
        sum += deg[i];
    }
    return hubs.empty() ? -res : res;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
