Submission #727073

# Submission time Handle Problem Language Result Execution time Memory
727073 2023-04-20T03:16:32 Z hoainiem Dreaming (IOI13_dreaming) C++14
0 / 100
38 ms 14484 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 sp = 0, res = inf;
    for (int i = 1; i < n; i++)
        if (dis[0][sp] < dis[0][i])
            sp = i;
    bfs(sp, 1);
    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 38 ms 14484 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 5360 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 38 ms 14484 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 22 ms 10308 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 5360 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 38 ms 14484 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -