Submission #654980

# Submission time Handle Problem Language Result Execution time Memory
654980 2022-11-02T10:13:34 Z noedit Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
3 ms 2772 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;

const int INF = 1e9;

const int MAXN = 1e5;

vector<pair<int, int> > g[MAXN];

vector<int> mark, d1, d2;

int n, m, k;

struct my
{
    int mn1 = INF, mn2 = INF, v = -1;
    my() {}
    my(int mn1, int mn2, int v) : mn1(mn1), mn2(mn2), v(v) {}
    bool operator<(const my& o) const
    {
        if (mn1 != o.mn1)
        {
            return mn1 < o.mn1;
        }
        if (mn2 != o.mn2)
        {
            return mn2 < o.mn2;
        }
        return v < o.v;
    }
};

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    n = N, m = M;
    for (int i = 0; i < m; i++)
    {
        g[R[i][0]].push_back({R[i][1], L[i]});
        g[R[i][1]].push_back({R[i][0], L[i]});
    }
    k = K;
    mark.resize(k);
    d1.resize(n, INF);
    d2.resize(n, INF);
    for (int i = 0; i < k; i++)
    {
        mark[i] = P[i];
    }
    set<pair<long long, int> > st;
    for (int i = 0; i < k; i++)
    {
        d1[mark[i]] = 0;
        d2[mark[i]] = 0;
        st.insert({0, mark[i]});
    }
    while (!st.empty())
    {
        auto[mn2, v] = *st.begin();
        st.erase(st.begin());
        for (auto&[u, w] : g[v])
        {
            if (d1[u] > mn2 + w)
            {
                d2[u] = d1[u];
                st.insert({d2[u], u});
                d1[u] = mn2 + w;
            }
            else
            {
                if (d2[u] > mn2 + w)
                {
                    st.erase({d2[u], u});
                    d2[u] = mn2 + w;
                    st.insert({d2[u], u});
                }
            }
        }
    }
    return d2[0];
}


# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 3 ms 2772 KB Output is correct
5 Incorrect 3 ms 2772 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 3 ms 2772 KB Output is correct
5 Incorrect 3 ms 2772 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 3 ms 2772 KB Output is correct
5 Incorrect 3 ms 2772 KB Output isn't correct
6 Halted 0 ms 0 KB -