답안 #963293

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
963293 2024-04-14T20:23:42 Z SuPythony 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
402 ms 66504 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

vector<vector<pair<int,int>>> al(100000, vector<pair<int,int>>());
vector<int> vis(100000,0);

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    for (int i=0; i<M; i++) {
        int u=R[i][0], v=R[i][1];
        al[u].push_back({v, L[i]});
        al[v].push_back({u, L[i]});
    }
    vector<vector<int>> time(100000, vector<int>(2, 1e9));
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>> pq;
    for (int i=0; i<K; i++) {
        pq.push({0,P[i]});
        time[P[i]][0]=time[P[i]][1]=0;
    }
    while (!pq.empty()) {
        int u=pq.top().second; pq.pop();
        if (vis[u]) continue;
        vis[u]=1;
        for (auto v: al[u]) {
            if (time[u][1]+v.second<=time[v.first][0]) {
                time[v.first][1]=time[v.first][0];
                time[v.first][0]=time[u][1]+v.second;
                pq.push({time[v.first][1],v.first});
            } else {
                if (time[u][1]+v.second<=time[v.first][1]) {
                    time[v.first][1]=time[u][1]+v.second;
                    pq.push({time[v.first][1],v.first});
                }
            }
        }
    }
    return time[0][1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12636 KB Output is correct
2 Correct 7 ms 12700 KB Output is correct
3 Correct 8 ms 12636 KB Output is correct
4 Correct 11 ms 12832 KB Output is correct
5 Correct 7 ms 12636 KB Output is correct
6 Correct 8 ms 12776 KB Output is correct
7 Correct 7 ms 12636 KB Output is correct
8 Correct 9 ms 12892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12636 KB Output is correct
2 Correct 7 ms 12700 KB Output is correct
3 Correct 8 ms 12636 KB Output is correct
4 Correct 11 ms 12832 KB Output is correct
5 Correct 7 ms 12636 KB Output is correct
6 Correct 8 ms 12776 KB Output is correct
7 Correct 7 ms 12636 KB Output is correct
8 Correct 9 ms 12892 KB Output is correct
9 Correct 8 ms 12892 KB Output is correct
10 Correct 7 ms 12636 KB Output is correct
11 Correct 8 ms 12636 KB Output is correct
12 Correct 10 ms 12892 KB Output is correct
13 Correct 9 ms 13084 KB Output is correct
14 Correct 8 ms 12800 KB Output is correct
15 Correct 10 ms 12632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12636 KB Output is correct
2 Correct 7 ms 12700 KB Output is correct
3 Correct 8 ms 12636 KB Output is correct
4 Correct 11 ms 12832 KB Output is correct
5 Correct 7 ms 12636 KB Output is correct
6 Correct 8 ms 12776 KB Output is correct
7 Correct 7 ms 12636 KB Output is correct
8 Correct 9 ms 12892 KB Output is correct
9 Correct 8 ms 12892 KB Output is correct
10 Correct 7 ms 12636 KB Output is correct
11 Correct 8 ms 12636 KB Output is correct
12 Correct 10 ms 12892 KB Output is correct
13 Correct 9 ms 13084 KB Output is correct
14 Correct 8 ms 12800 KB Output is correct
15 Correct 10 ms 12632 KB Output is correct
16 Correct 328 ms 61932 KB Output is correct
17 Correct 79 ms 21704 KB Output is correct
18 Correct 100 ms 22620 KB Output is correct
19 Correct 402 ms 66504 KB Output is correct
20 Correct 218 ms 55892 KB Output is correct
21 Correct 48 ms 16864 KB Output is correct
22 Correct 245 ms 53748 KB Output is correct