답안 #656210

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
656210 2022-11-06T13:59:53 Z benjaminkleyn 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
564 ms 89276 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
typedef long long ll;
 
int n;
vector<pair<int,ll>> g[100000];
ll dist[100000][2];
bool vis[100000];
 
void dijkstra(int K, int P[])
{
    for (int i = 0; i < n; i++)
    {
        dist[i][0] = dist[i][1] = LLONG_MAX; 
        vis[i] = false;
    }
 
    priority_queue<pair<ll,int>> pq;
    for (int i = 0; i < K; i++)
    {
        pq.push({0LL, P[i]});
        dist[P[i]][0] = dist[P[i]][1] = 0LL;
    }
 
    while (!pq.empty())
    {
        int u = pq.top().second;
        pq.pop();
        if (vis[u]) continue;
        vis[u] = true;
 
        for (auto [v, l] : g[u])
            if (!vis[v])
                if (dist[u][1] + l < dist[v][1])
                {
                    dist[v][1] = dist[u][1] + l;
                    if (dist[v][1] < dist[v][0])
                        swap(dist[v][0], dist[v][1]);
                    if (dist[v][1] != LLONG_MAX)
                        pq.push({-dist[v][1], v});
                }
    }
 
}
 
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    n = N;
    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]});
    }
    dijkstra(K, P);
    return dist[0][1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 4 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 4 ms 2804 KB Output is correct
8 Correct 3 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 4 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 4 ms 2804 KB Output is correct
8 Correct 3 ms 2772 KB Output is correct
9 Correct 6 ms 3028 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 4 ms 2772 KB Output is correct
12 Correct 6 ms 3412 KB Output is correct
13 Correct 5 ms 3412 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 4 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 4 ms 2804 KB Output is correct
8 Correct 3 ms 2772 KB Output is correct
9 Correct 6 ms 3028 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 4 ms 2772 KB Output is correct
12 Correct 6 ms 3412 KB Output is correct
13 Correct 5 ms 3412 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2772 KB Output is correct
16 Correct 451 ms 82956 KB Output is correct
17 Correct 71 ms 17708 KB Output is correct
18 Correct 91 ms 20192 KB Output is correct
19 Correct 564 ms 89276 KB Output is correct
20 Correct 321 ms 67956 KB Output is correct
21 Correct 45 ms 9692 KB Output is correct
22 Correct 310 ms 64176 KB Output is correct