답안 #238568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238568 2020-06-11T21:58:42 Z arbor 꿈 (IOI13_dreaming) C++14
18 / 100
62 ms 15352 KB
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MN = 1e5 + 5;
vector<pii> g[MN];
int rt, D, R, dis[MN];
bool vis[MN];

void dfs(int u, int p, int d, bool qu) {
    vis[u] = true;
    if (d >= D) D = d, rt = u;
    if (qu) R = min(R, max(d, dis[u]));
    else dis[u] = d;
    for (pii e : g[u]) if (e.first != p) {
        dfs(e.first, u, d + e.second, qu);
    }
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    for (int i = 0; i < M; i++) {
        int u = A[i], v = B[i], w = T[i];
        g[u].emplace_back(v, w);
        g[v].emplace_back(u, w);
    }
    vector<pii> lens;
    for (int i = 0; i < N; i++) {
        if (!vis[i]) {
            D = 0, R = INT_MAX;
            dfs(i, -1, 0, 0);
            dfs(rt, -1, 0, 0);
            dfs(rt, -1, 0, 1);
            lens.emplace_back(R, D);
        }
    }
    sort(lens.rbegin(), lens.rend());
    if (lens.size() == 1) return lens[0].second;
    else if (lens.size() == 2) return lens[0].first + L + lens[1].first;
    else return max(lens[0].first + L + lens[1].first, lens[1].first + 2 * L + lens[2].first);
}

/* 
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int a[] = {0,8,2,5,5,1,1,10};
    int b[] = {8,2,7,11,1,3,9,6};
    int c[] = {4,2,4,3,7,1,5,3};
    cout << travelTime(12,8,2,a,b,c) << '\n';
    return 0;
}   
*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 62 ms 15352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 62 ms 15352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 62 ms 15352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 6528 KB Output is correct
2 Correct 32 ms 6528 KB Output is correct
3 Correct 30 ms 6528 KB Output is correct
4 Correct 29 ms 6528 KB Output is correct
5 Correct 32 ms 6580 KB Output is correct
6 Correct 32 ms 7292 KB Output is correct
7 Correct 31 ms 6784 KB Output is correct
8 Correct 31 ms 6520 KB Output is correct
9 Correct 29 ms 6388 KB Output is correct
10 Correct 33 ms 6652 KB Output is correct
11 Correct 6 ms 2688 KB Output is correct
12 Correct 11 ms 4344 KB Output is correct
13 Correct 13 ms 4344 KB Output is correct
14 Correct 11 ms 4344 KB Output is correct
15 Correct 11 ms 4344 KB Output is correct
16 Correct 11 ms 4344 KB Output is correct
17 Correct 12 ms 4344 KB Output is correct
18 Correct 11 ms 4472 KB Output is correct
19 Correct 11 ms 4344 KB Output is correct
20 Correct 6 ms 2688 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 6 ms 2816 KB Output is correct
23 Correct 12 ms 4344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 62 ms 15352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 62 ms 15352 KB Output isn't correct
2 Halted 0 ms 0 KB -