답안 #966965

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
966965 2024-04-20T17:56:17 Z Hugo1729 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
682 ms 79976 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;

vector<pair<int,int>> adj[100000];
int visited[100000]={0};

int dp[100000]={0};

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    for(int i=0;i<K;i++)visited[P[i]]=2;

    priority_queue<pair<int,int>> pq;

    for(int i=0;i<M;i++){
        int v=R[i][0],w=R[i][1];
        if(!(visited[v]==2&&visited[w]==2)){
            if(!(visited[v]==2))swap(v,w);
            if(visited[v])pq.push({-L[i],w});
        }
        adj[R[i][0]].push_back({R[i][1],L[i]});
        adj[R[i][1]].push_back({R[i][0],L[i]});
    }

    while(!pq.empty()){
        int d = -pq.top().first, v = pq.top().second;
        // cout << "s" << v << ' ' << d << '\n';
        pq.pop();

        if(visited[v]==2)continue;
        else if(visited[v]==1){
            visited[v]=2;
            dp[v]=d;
            for(pair<int,int> _ : adj[v]){
                int w=_.first, t=_.second;
                pq.push({-(t+d),w});
                // cout << "a" << w << ' ' << -(t+d) << '\n';
            }
        }else{
            visited[v]=1;
        }
    }


    // cout << pq.top().first;

    // for(int i=0;i<n;i++)cout << dp[i] << ' ';
    // cout << '\n';

    return dp[0];
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 3 ms 6936 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 6 ms 7268 KB Output is correct
13 Correct 6 ms 7260 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 3 ms 6936 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 6 ms 7268 KB Output is correct
13 Correct 6 ms 7260 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 622 ms 77056 KB Output is correct
17 Correct 66 ms 16724 KB Output is correct
18 Correct 87 ms 18000 KB Output is correct
19 Correct 682 ms 79976 KB Output is correct
20 Correct 456 ms 71864 KB Output is correct
21 Correct 34 ms 10388 KB Output is correct
22 Correct 461 ms 52176 KB Output is correct