답안 #371054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
371054 2021-02-25T17:08:16 Z Peti 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
873 ms 101024 KB
#include <bits/stdc++.h>
#include "crocodile.h"

using namespace std;

vector<vector<pair<int, long long>>> g;
vector<bool> volt[2];
vector<long long> tav;

void dijkstra(vector<int> v){
    priority_queue<pair<long long, int>> pq;

    for(int i = 0; i < (int)v.size(); i++){
        volt[0][v[i]] = true;
        pq.push(make_pair(0, v[i]));
    }

    while(pq.size() > 0){
        while(pq.size() > 0 && volt[0][pq.top().second] && volt[1][pq.top().second])
            pq.pop();
        if(pq.size() == 0)
            break;
        int x = pq.top().second;
        long long y = -pq.top().first;
        pq.pop();
        if(!volt[0][x]){
            volt[0][x] = true;
            continue;
        }else{
            volt[1][x] = true;
            tav[x] = y;
        }

        for(pair<int, long long> e : g[x])
            if(!volt[1][e.first])
                pq.push(make_pair(-(y + e.second), e.first));
    }
    return;
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    g.resize(N);
    volt[0].resize(N, false);
    volt[1].resize(N, false);
    tav.resize(N, (long long)1e18);

    for(int i = 0; i < M; i++){
        g[R[i][0]].push_back(make_pair(R[i][1], L[i]));
        g[R[i][1]].push_back(make_pair(R[i][0], L[i]));
    }

    vector<int> v;
    for(int i = 0; i < K; i++)
        v.push_back(P[i]);
    dijkstra(v);

    return tav[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 3 ms 1004 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 3 ms 620 KB Output is correct
12 Correct 6 ms 1392 KB Output is correct
13 Correct 5 ms 1516 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 3 ms 1004 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 3 ms 620 KB Output is correct
12 Correct 6 ms 1392 KB Output is correct
13 Correct 5 ms 1516 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 806 ms 95968 KB Output is correct
17 Correct 85 ms 16988 KB Output is correct
18 Correct 118 ms 19412 KB Output is correct
19 Correct 873 ms 101024 KB Output is correct
20 Correct 499 ms 82192 KB Output is correct
21 Correct 44 ms 7916 KB Output is correct
22 Correct 512 ms 62832 KB Output is correct