답안 #667092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
667092 2022-11-30T11:26:53 Z ansgar 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vb vector<bool>
#define vc vector<char>
#define vvc vector<vc>
#define vvb vector<vb>
#define si set<int>
#define mii map<int,int>

const int mod=1e9+7;
const int N=2e5+1;
const int LN=LLONG_MAX/10;
struct com{
    bool operator()(pair<pii,int>& a,pair<pii,int>& b){
        return a.second>b.second;
    }
};
struct co{
    bool operator()(pii& a,pii& b){
        return a.second>b.second;
    }
};
int travel_plan(int n,int m,int R[][2],int L[],int k,int P[]){
    vvpii 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<pii,int>,vector<pair<pii,int>>,com> Q;
    for(int i=0;i<k;i++){
        Q.push({{P[i],P[i]},0});
    }
    vi bloq(n,LN);
    while(Q.size()){
        int u=Q.top().first.first;
        int p=Q.top().first.second;
        int wu=Q.top().second;
        Q.pop();
        if(bloq[u]!=LN)continue;
        bloq[u]=p;
        for(auto x : G[u]){
            int v=x.first;
            int wv=x.second;
            if(bloq[v]==LN)Q.push({{v,u},wu+wv});
        }
    }
    vi dist(n,LN);
    priority_queue<pii,vpii,co> Q2;
    Q2.push({0,0});
    while(Q2.size()){
        int u=Q2.top().first;
        int wu=Q2.top().second;
        Q2.pop();
        if(dist[u]!=LN)continue;
        dist[u]=wu;
        for(auto x : G[u]){
            int v=x.first;
            int wv=x.second;
            if(bloq[u]==v)continue;
            if(dist[v]==LN)Q2.push({v,wu+wv});
        }
    }
    int sol=LN;
    for(int i=0;i<k;i++){
        sol=min(sol,dist[P[i]]);
    }
    if(sol==LN)return -1;
    return sol;
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    int R[m][2];
    int L[m];
    int k;
    for(int i=0;i<m;i++)cin>>R[i][0]>>R[i][1];
    for(int i=0;i<m;i++)cin>>L[i];
    cin>>k;
    int P[k];
    for(int i=0;i<k;i++)cin>>P[i];
    cout<<travel_plan(n,m,R,L,k,P);
}

Compilation message

/usr/bin/ld: /tmp/cc55I15B.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cctoCRwG.o:crocodile.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc55I15B.o: in function `main':
grader.cpp:(.text.startup+0x36): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status