답안 #978554

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978554 2024-05-09T10:30:44 Z tnknguyen_ 공장들 (JOI14_factories) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "factories.h"
using namespace std;
#define endl '\n' 
#define ll long long 
#define len(s) (int)s.size() 
#define pii pair<int, int>
//#define int long long 

const int MX = 5e5 + 5;
const int LG = 19;
vector<pii> gr[MX];
ll up[LG][MX], f[LG][MX], dep[MX];
int n, q;

void Init(int N, int A[], int B[], int D[]){
    n = N;
    for(int i=0; i<n; ++i){
        int u = A[i], v = B[i], c = D[i];
        ++u, ++v;
        gr[u].push_back({v, c});
        gr[v].push_back({u, c});
    }

    dfs(1, 1);
}

ll Query(int S, int X[], int T, int Y[]){
    ll ans = 1e18;

    vector<ll> dist(n + 5, 1e18);
    priority_queue<pair<ll, ll>> q;
    for(int i=0; i<S; ++i){
        dist[X[i] + 1] = 0;
        q.push({0, X[i] + 1});
    }

    while(q.size()){
        ll w, u;
        tie(w, u) = q.top();
        w = -w;
        q.pop();

        for(pii e : gr[u]){
            ll v, c;
            tie(v, c) = e;
            if(w + c < dist[v]){
                dist[v] = w + c;
                q.push({-dist[v], v});
            }
        }
    }

    for(int i=0; i<T; ++i){
        ans = min(ans, dist[Y[i] + 1]);
    }

    return ans;
}

Compilation message

factories.cpp: In function 'void Init(int, int*, int*, int*)':
factories.cpp:25:5: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   25 |     dfs(1, 1);
      |     ^~~
      |     ffs