답안 #654983

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
654983 2022-11-02T10:26:04 Z noedit 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
664 ms 62504 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;

const int INF = 2e9;

const int MAXN = 1e5;

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

vector<int> mark;
vector<long long> 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)
            {
                st.erase({d2[u], u});
                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];
}


# 결과 실행 시간 메모리 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 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2668 KB Output is correct
7 Correct 3 ms 2668 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 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 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2668 KB Output is correct
7 Correct 3 ms 2668 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 3 ms 2900 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 2 ms 2708 KB Output is correct
12 Correct 4 ms 3100 KB Output is correct
13 Correct 4 ms 3192 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
# 결과 실행 시간 메모리 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 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2668 KB Output is correct
7 Correct 3 ms 2668 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 3 ms 2900 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 2 ms 2708 KB Output is correct
12 Correct 4 ms 3100 KB Output is correct
13 Correct 4 ms 3192 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
16 Correct 465 ms 56404 KB Output is correct
17 Correct 68 ms 14540 KB Output is correct
18 Correct 114 ms 16356 KB Output is correct
19 Correct 664 ms 62504 KB Output is correct
20 Correct 234 ms 49608 KB Output is correct
21 Correct 38 ms 7804 KB Output is correct
22 Correct 274 ms 46204 KB Output is correct