답안 #923152

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923152 2024-02-06T18:35:51 Z AlphaMale06 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
882 ms 104880 KB
#include<bits/stdc++.h>
#include "crocodile.h"

using namespace std;
using ll = long long;
#define F first
#define S second
#define pb push_back

const int mxn = 1e5+10;

vector<pair<ll, ll>> adj[mxn];
ll dist[mxn][2];
bool mark[mxn];

int travel_plan(int n, int m, int R[][2], int L[], int K, int P[])
{
    for(int i=0; i< m; i++){
        adj[R[i][0]].pb({R[i][1], L[i]});
        adj[R[i][1]].pb({R[i][0], L[i]});
    }
    for(int i=0; i<n; i++)dist[i][0]=dist[i][1]=1e14;
    set<pair<pair<ll, ll>, ll>> st;
    for(int i=0; i<K; i++){
        int v=P[i];
        mark[v]=1;
        dist[v][0]=dist[v][1]=0;
    }
    for(int i=0; i<K; i++){
        int v=P[i];
        for(auto to : adj[v]){
            if(to.S<dist[to.F][0]){
                dist[to.F][1]=dist[to.F][0];
                dist[to.F][0]=to.S;
            }
            else if(to.S<dist[to.F][1]){
                dist[to.F][1]=to.S;
            }
        }
    }
    for(int i=0; i< n; i++)st.insert({{dist[i][1], dist[i][0]}, i});
    while(st.size()){
        int v = (*st.begin()).S;
        if(mark[v]){
            st.erase((*st.begin()));
            continue;
        }
        mark[v]=1;
        for(auto to : adj[v]){
            if(!mark[to.F]){
                if(to.S+dist[v][1]<dist[to.F][0]){
                    dist[to.F][1]=dist[to.F][0];
                    dist[to.F][0]=to.S+dist[v][1];
                }
                else if(to.S+dist[v][1]<dist[to.F][1]){
                    dist[to.F][1]=dist[v][1]+to.S;
                }
                st.insert({{dist[to.F][1], dist[to.F][0]}, to.F});
            }
        }
    }
    return dist[0][1];
}



# 결과 실행 시간 메모리 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 6744 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 2 ms 6748 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 6744 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 2 ms 6748 KB Output is correct
9 Correct 3 ms 6748 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6744 KB Output is correct
12 Correct 4 ms 7004 KB Output is correct
13 Correct 4 ms 7120 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6748 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 6744 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 2 ms 6748 KB Output is correct
9 Correct 3 ms 6748 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6744 KB Output is correct
12 Correct 4 ms 7004 KB Output is correct
13 Correct 4 ms 7120 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6748 KB Output is correct
16 Correct 677 ms 88424 KB Output is correct
17 Correct 113 ms 32408 KB Output is correct
18 Correct 145 ms 33876 KB Output is correct
19 Correct 882 ms 104880 KB Output is correct
20 Correct 310 ms 70648 KB Output is correct
21 Correct 48 ms 18004 KB Output is correct
22 Correct 349 ms 71072 KB Output is correct