Submission #716996

# Submission time Handle Problem Language Result Execution time Memory
716996 2023-03-31T18:59:00 Z HaroldVemeno Dreaming (IOI13_dreaming) C++17
18 / 100
61 ms 10768 KB
#include "dreaming.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int rd[100000];
bool vis[100000];
struct W {
    int t;
    int w;
};
vector<vector<W>> al;

void calcrd(int v, int p) {
    vis[v] = true;
    int mrd = 0;
    for(auto a : al[v]) {
        if(a.t == p) continue;
        calcrd(a.t, v);
        mrd = max(mrd, a.w + rd[a.t]);
    }
    rd[v] = mrd;
}

int radius(int v, int p, int tdist) {
    int mrv = -1;
    int mr = tdist;
    int mr2 = tdist;
    for(auto a : al[v]) {
        if(a.t == p) continue;
        if(rd[a.t] + a.w >= mr) {
            mrv = a.t;
            mr2 = mr;
            mr = rd[a.t] + a.w;
        } else if(rd[a.t] + a.w >= mr2) {
            mr2 = rd[a.t] + a.w;
        }
    }
    int br = mr;
    for(auto a : al[v]) {
        if(a.t == p) continue;
        if(a.t == mrv) {
            br = min(br, radius(a.t, v, mr2 + a.w));
        } else {
            br = min(br, radius(a.t, v, mr + a.w));
        }
    }
    return br;
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    al.assign(N, {});
    for(int i = 0; i < M; ++i) {
        al[A[i]].push_back({B[i], T[i]});
        al[B[i]].push_back({A[i], T[i]});
    }
    vector<int> rads;
    for(int i = 0; i < N; ++i) {
        if(vis[i]) continue;
        calcrd(i, i);
        rads.push_back(radius(i, i, 0));
    }
    sort(rbegin(rads), rend(rads));
    if(rads.size() == 1) return rads[0];
    if(rads.size() == 2) return rads[0] + L + rads[1];
    return max(rads[0] + rads[1] + L, rads[1] + 2*L + rads[2]);
}
# Verdict Execution time Memory Grader output
1 Incorrect 61 ms 10768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 61 ms 10768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 5592 KB Output is correct
2 Correct 20 ms 5716 KB Output is correct
3 Correct 17 ms 5592 KB Output is correct
4 Correct 21 ms 5628 KB Output is correct
5 Correct 23 ms 5588 KB Output is correct
6 Correct 31 ms 6132 KB Output is correct
7 Correct 24 ms 5848 KB Output is correct
8 Correct 29 ms 5588 KB Output is correct
9 Correct 22 ms 5540 KB Output is correct
10 Correct 21 ms 5772 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 4 ms 3792 KB Output is correct
13 Correct 4 ms 3792 KB Output is correct
14 Correct 6 ms 3792 KB Output is correct
15 Correct 5 ms 3792 KB Output is correct
16 Correct 5 ms 3792 KB Output is correct
17 Correct 4 ms 3664 KB Output is correct
18 Correct 5 ms 3792 KB Output is correct
19 Correct 6 ms 3792 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 5 ms 3792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 61 ms 10768 KB Output isn't correct
2 Halted 0 ms 0 KB -