Submission #456127

# Submission time Handle Problem Language Result Execution time Memory
456127 2021-08-06T06:50:16 Z PPAP_1264589 Dreaming (IOI13_dreaming) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define pii pair<int, int>
#define f first
#define s second
#define up(i, a, b) for (int i = (a); i <= (b); i++)
#define pb push_back
#define int long long
using namespace std;
 
const int oo = 2*100000000000000000;
const int maxn = 100001;
int n, m, L;
vector<pii> a[maxn];
 
void in(){
    cin >> n >> m >> L;
    int u,v,w;
    up(i, 1, m){
        cin >> u >> v >> w;
        u++;
        v++;
        a[u].pb({v, w});
        a[v].pb({u, w});
    }
}
 
int cost[maxn];
bool dd[maxn];
int dx[maxn];
int dy[maxn];
vector<int> luu;
int maxx;
 
void DFS(int u, int parent, int d[]){
    dd[u] = 1;
    luu.emplace_back(u);
    for (pii x : a[u]){
        int v = x.f;
        int w = x.s;
        if (v == parent) continue;
 
        d[v] = d[u] + w;
        DFS(v, u, d);
    }
}
 
vector<int> R;
int minn = oo;
void find_center(int root){
    DFS(root, -1, cost);
 
    int X = max_element(cost+1, cost+n+1) - cost;
    DFS(X, -1, dx);
    int Y = max_element(dx+1, dx+n+1) - dx;
    DFS(Y, -1, dy);
 
    minn = oo;
    for (auto x : luu){
        minn = min(minn, max(dx[x], dy[x]));
    }
    R.push_back(minn);
 
    for (auto x : luu){
        cost[x] = dx[x] = dy[x] = 0;
    }
    luu.clear();
}
 
signed main(){
    in();
    up(root, 1, n){
        if (!dd[root]){
            find_center(root);
        }
    }
    int tplt = R.size();
 
    if (tplt == 1){
        cout << minn;
    }
    sort(R.begin(), R.end(), greater<int>());
 
    int maxx = -oo;
    if (tplt > 1){
        maxx = max(maxx, R[0] + R[1] + L);
    }
    if (tplt > 2){
        maxx = max(maxx, R[1] + R[2] + 2*L);
    }
    cout << maxx;
}

Compilation message

/usr/bin/ld: /tmp/ccfxurMK.o: in function `main':
dreaming.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cco6lZ0G.o:grader.c:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cco6lZ0G.o: in function `main':
grader.c:(.text.startup+0xd1): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status