답안 #97168

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97168 2019-02-14T08:47:52 Z Alexa2001 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
925 ms 63828 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> Pair;
const int Nmax = 1e5 + 5;

vector<Pair> v[Nmax];
priority_queue< Pair, vector<Pair>, greater<Pair> > heap;

int dist[Nmax];
bool used[Nmax];
vector<int> best[Nmax];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    int i;
    for(i=0; i<M; ++i)
    {
        int x, y, cost;
        x = R[i][0]; y = R[i][1];
        cost = L[i];
        v[x].push_back({y, cost});
        v[y].push_back({x, cost});
    }

    for(i=0; i<N; ++i) best[i].resize(2, 2e9);

    for(i=0; i<K; ++i) heap.push({0, P[i]});

    while(heap.size())
    {
        int node, cost;
        tie(cost, node) = heap.top();
        heap.pop();
        if(used[node]) continue;

        used[node] = 1;
        dist[node] = cost;
        if(node == 0) break;

        for(auto it : v[node])
        {
            int x, l;
            tie(x, l) = it;
            if(used[x]) continue;

            int curr_best = best[x][1];

            best[x].push_back(dist[node] + l);
            sort(best[x].begin(), best[x].end());
            best[x].pop_back();

            if(best[x][1] < curr_best)
                heap.push({best[x][1], x});
        }
    }
    return dist[0];
}

# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5120 KB Output is correct
2 Correct 7 ms 4992 KB Output is correct
3 Correct 8 ms 5120 KB Output is correct
4 Correct 7 ms 5120 KB Output is correct
5 Correct 9 ms 5248 KB Output is correct
6 Correct 7 ms 5120 KB Output is correct
7 Correct 9 ms 5248 KB Output is correct
8 Correct 9 ms 5248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5120 KB Output is correct
2 Correct 7 ms 4992 KB Output is correct
3 Correct 8 ms 5120 KB Output is correct
4 Correct 7 ms 5120 KB Output is correct
5 Correct 9 ms 5248 KB Output is correct
6 Correct 7 ms 5120 KB Output is correct
7 Correct 9 ms 5248 KB Output is correct
8 Correct 9 ms 5248 KB Output is correct
9 Correct 10 ms 5248 KB Output is correct
10 Correct 8 ms 5120 KB Output is correct
11 Correct 9 ms 5120 KB Output is correct
12 Correct 13 ms 5504 KB Output is correct
13 Correct 12 ms 5548 KB Output is correct
14 Correct 7 ms 5120 KB Output is correct
15 Correct 7 ms 5120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5120 KB Output is correct
2 Correct 7 ms 4992 KB Output is correct
3 Correct 8 ms 5120 KB Output is correct
4 Correct 7 ms 5120 KB Output is correct
5 Correct 9 ms 5248 KB Output is correct
6 Correct 7 ms 5120 KB Output is correct
7 Correct 9 ms 5248 KB Output is correct
8 Correct 9 ms 5248 KB Output is correct
9 Correct 10 ms 5248 KB Output is correct
10 Correct 8 ms 5120 KB Output is correct
11 Correct 9 ms 5120 KB Output is correct
12 Correct 13 ms 5504 KB Output is correct
13 Correct 12 ms 5548 KB Output is correct
14 Correct 7 ms 5120 KB Output is correct
15 Correct 7 ms 5120 KB Output is correct
16 Correct 782 ms 59604 KB Output is correct
17 Correct 132 ms 18936 KB Output is correct
18 Correct 163 ms 20232 KB Output is correct
19 Correct 925 ms 63828 KB Output is correct
20 Correct 373 ms 52120 KB Output is correct
21 Correct 58 ms 11000 KB Output is correct
22 Correct 415 ms 49272 KB Output is correct