답안 #857878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
857878 2023-10-07T06:27:23 Z asdasdqwer 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
397 ms 69272 KB
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int, int>
#define pll pair<int64_t, int64_t>

int travel_plan(int n, int m, int R[][2], int L[], int k, int p[]) {
    vector<vector<pii>> g(n);

    for (int i=0;i<m;i++) {
        int a = R[i][0], b = R[i][1];
        int c = L[i];

        g[a].push_back({b, c});
        g[b].push_back({a, c});
    }

    vector<pll> dist(n, make_pair((int)1e16, (int)1e16));
    for (int i=0;i<k;i++) {
        dist[p[i]] = {0, 0};
    }

    priority_queue<pll> pq;
    for (int i=0;i<n;i++) {
        pq.push({-dist[i].second, i});
    }
    vector<bool> proc(n, false);

    while (!pq.empty()) {
        pii t=pq.top();pq.pop();
        int node=t.second;
        if (proc[node]) continue;
        proc[node] = true;

        for (auto x:g[node]) {
            if (dist[node].second + x.second < dist[x.first].first) {
                dist[x.first].second = dist[x.first].first;
                dist[x.first].first = dist[node].second + x.second;
                pq.push({-dist[x.first].second, x.first});
            }

            else if (dist[node].second + x.second < dist[x.first].second) {
                dist[x.first].second = dist[node].second + x.second;
                pq.push({-dist[x.first].second, x.first});
            }
        }
    }

    return dist[0].second;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4552 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4552 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4552 KB Output is correct
9 Correct 2 ms 4700 KB Output is correct
10 Correct 1 ms 4696 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 4 ms 4912 KB Output is correct
13 Correct 3 ms 4968 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4552 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4552 KB Output is correct
9 Correct 2 ms 4700 KB Output is correct
10 Correct 1 ms 4696 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 4 ms 4912 KB Output is correct
13 Correct 3 ms 4968 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 334 ms 60020 KB Output is correct
17 Correct 80 ms 21700 KB Output is correct
18 Correct 96 ms 22940 KB Output is correct
19 Correct 397 ms 69272 KB Output is correct
20 Correct 211 ms 48176 KB Output is correct
21 Correct 35 ms 10588 KB Output is correct
22 Correct 239 ms 47424 KB Output is correct