답안 #272221

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
272221 2020-08-18T10:55:37 Z Toirov_Sadi 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
827 ms 63724 KB
#include <bits/stdc++.h>
#include "crocodile.h"

using namespace std;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    vector<pair<int, int>> g[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]});
    }
    priority_queue<pair<int, int>> q;
    vector<int> mn1(N, INT_MAX);
    vector<int> mn2(N, INT_MAX);

    for(int i = 0; i < K; i ++){
        mn1[P[i]] = mn2[P[i]] = 0;
        q.push({0, P[i]});
    }
    vector<int> used(N, 0);
    while(!q.empty()){
        int v = q.top().second;
        q.pop();
        if(used[v] == 1) continue;

        used[v] = 1;
        for(auto to: g[v]){
            if(mn1[to.first] >= mn2[v] + to.second){
                mn2[to.first] = mn1[to.first];
                mn1[to.first] = mn2[v] + to.second;
                q.push({-mn2[to.first], to.first});
            }
            else if(mn2[to.first] > mn2[v] + to.second){
                mn2[to.first] = mn2[v] + to.second;
                q.push({-mn2[to.first], to.first});
            }
        }
    }
    return mn2[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 4 ms 896 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 4 ms 896 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 568 ms 56848 KB Output is correct
17 Correct 120 ms 15348 KB Output is correct
18 Correct 148 ms 16756 KB Output is correct
19 Correct 827 ms 63724 KB Output is correct
20 Correct 332 ms 47328 KB Output is correct
21 Correct 54 ms 6648 KB Output is correct
22 Correct 424 ms 44924 KB Output is correct