| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 743771 | rominanafu | Crocodile's Underground City (IOI11_crocodile) | C++11 | 571 ms | 66640 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pii pair<int,int>
 
using namespace std;
typedef long long ll;
 
vector<pii > edge[100005];
pii tiempo[100005];
bool vis[100005];
priority_queue<pii > q;
 
void tiempo_min() {
    int costo, nodo, c;
    while (!q.empty()) {
        costo = q.top().first;
        nodo = q.top().second;
        q.pop();
        while(!q.empty() && vis[nodo]) {
            costo = q.top().first;
            nodo = q.top().second;
            q.pop();
        }
        if (vis[nodo]) /// poner vis[nodo]=true cuando tenga los dos caminos mínimos
            break;
        costo *= -1;
        if (tiempo[nodo].first == -1) {
            tiempo[nodo].first = costo;
            continue;
        }
        tiempo[nodo].second = costo;
        vis[nodo] = true;
        for(auto v:edge[nodo]) {
            if (vis[v.first])
                continue;
            c = costo + v.second;
            c *= -1;
            q.push({c, v.first});
        }
    }
}
 
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[])
{
    memset(tiempo, -1, sizeof(tiempo));
    int a, b, t;
    for(int i=0; i<m; i++) {
        a = R[i][0];
        b = R[i][1];
        t = L[i];
        edge[a].push_back({b, t});
        edge[b].push_back({a, t});
    }
    for(int i=0; i<k; i++) {
        a = P[i];
        vis[a] = true;
        tiempo[a].first = 0;
        tiempo[a].second = 0;
        for(auto v:edge[a]) {
            q.push({v.second * (-1), v.first});
        }
    }
    tiempo_min();
    return tiempo[0].second;
}
 
/**
4 4 1
0 1 9
0 3 10
1 2 40
2 3 100
2
(-1)
9 9 5
0 1 1
0 2 4
1 3 6
1 4 2
2 5 3
2 6 8
6 5 100
6 7 40
6 8 1
3 4 5 7 8
(52)
**/
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
