답안 #119873

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
119873 2019-06-22T14:21:50 Z dolphingarlic 꿈 (IOI13_dreaming) C++14
0 / 100
53 ms 10488 KB
#include "dreaming.h"
#include <bits/stdc++.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, r[2], indx = 0;
bool visited[100001];

void dfs(ll node, ll parent = -1) {
    visited[node] = true;
    for (auto& i : graph[node]) {
        if (i.first == parent) continue;
        len += i.second;
        dfs(i.first, node);
    }
}
ll dfs2(ll node, ll parent = -1, ll left = 0) {
    for (auto& i : graph[node]) {
        if (i.first == parent) continue;
        return min(max(left, len - left), dfs2(i.first, node, left + i.second));
    }
    return len;
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    fill(visited, visited + N, false);
    FOR(i, 0, M) {
        graph[A[i]].push_back({B[i], T[i]});
        graph[B[i]].push_back({A[i], T[i]});
    }

    FOR(i, 0, N) {
        if (graph[i].size() == 1 && !visited[i]) {
            len = 0;
            dfs(i);
            r[indx++] = dfs2(i);
        }
    }
    cout << r[0] + r[1] + L << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 10488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 10488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 10488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 10072 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 10488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 10488 KB Output isn't correct
2 Halted 0 ms 0 KB -