Submission #727076

# Submission time Handle Problem Language Result Execution time Memory
727076 2023-04-20T03:18:29 Z hoainiem Dreaming (IOI13_dreaming) C++14
0 / 100
34 ms 13320 KB
#include "dreaming.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define nmax 100008
const int inf = 1e9 + 7;
using namespace std;
typedef pair<int, int> pii;
vector<pii>vt, l[nmax];
bool kt[nmax];
int n, dis[2][nmax];
stack<int>s;
void bfs(int root, int id){
    fill(dis[id], dis[id] + nmax, -1);
    s.push(root);
    dis[id][root] = 0;
    while (!s.empty()){
        int u = s.top();
        s.pop();
        for (pii it : l[u])
            if (dis[id][it.fi] == -1){
                dis[id][it.fi] = dis[id][u] + it.se;
                s.push(it.fi);
            }
    }
}
pii calc(int rt){
    bfs(rt, 0);
    int u = 0, v = 0, res = inf;
    for (int i = 1; i < n; i++)
        if (dis[0][u] < dis[0][i])
            u = i;
    bfs(u, 1);
    for (int i = 1; i < n; i++)
        if (dis[1][v] < dis[1][i])
            v = i;
    bfs(v, 0);
    for (int i = 0; i < n; i++)
        res = min(res, max(dis[0][i], dis[1][i]));
    return {dis[0][rt], res};
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    n = N;
    for (int i = 0; i < M; i++){
        int u = A[i], v = B[i], w = T[i];
        l[u].push_back({v, w});
        l[v].push_back({u, w});
    }
    assert(M == N - 2);
    memset(kt, false, sizeof(kt));
    for (int i = 0; i < N; i++)
        if (!kt)
            vt.push_back(calc(i));
    return vt[0].se + vt[1].se + L;
}
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 13320 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 5332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 13320 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 9940 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 5332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 13320 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -