Submission #119897

# Submission time Handle Problem Language Result Execution time Memory
119897 2019-06-22T15:02:18 Z dolphingarlic Dreaming (IOI13_dreaming) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "dreaming.h"
#pragma GCC optimize("O3")
#define FOR(i, x, y) for (ll i = x; i < y; i++)
typedef long long ll;
using namespace std;

vector<pair<ll, ll>> graph[100001];
ll len, ans = 0, r[100001], indx = 0, cmp[100001];
pair<ll, ll> dp[100001];
bool visited[100001];

void ff(int node, int component, int parent = -1) {
    visited[node] = true;
    cmp[node] = component;
    for (auto& i : graph[node]) {
        if (i.first == parent) continue;
        ff(i.first, component, node);
    }
}

void dfs(ll node, ll parent = -1) {
    int mx1 = 0, mx2 = 0;
    for (auto& i : graph[node]) {
        if (i.first == parent) continue;
        dfs(i.first, node);

        int e = dp[i.first].first + i.second;
        if (e > mx1) {
            mx2 = mx1;
            mx1 = e;
        } else if (e > mx2)
            mx2 = e;
    }
    dp[node] = {mx1, mx2};
}

int main() {
    int N, M, L;
    cin >> N >> M >> L;
    FOR(i, 0, M) {
        int A, B, T;
        cin >> A >> B >> T;
        graph[A].push_back({B, T});
        graph[B].push_back({A, T});
    }

    fill(visited, visited + N, false);
    FOR(i, 0, N) if (!visited[i]) ff(i, indx++);

    fill(r, r + indx, INT_MAX);
    FOR(i, 0, N) {
        dfs(i);
        r[cmp[i]] = min(r[cmp[i]], dp[i].first);
        ans = max(ans, dp[i].first + dp[i].second);
    }
    sort(r, r + indx, greater<ll>());

    ans = max(ans, max((indx > 2 ? r[1] + r[2] + 2 * L : 0),
                       max((indx > 1 ? r[0] + r[1] + L : 0), r[0])));
    return ans;
}

Compilation message

/tmp/ccVqxjKU.o: In function `main':
dreaming.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc1SpQJ9.o:grader.c:(.text.startup+0x0): first defined here
/tmp/cc1SpQJ9.o: In function `main':
grader.c:(.text.startup+0xa2): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status