Submission #566640

#TimeUsernameProblemLanguageResultExecution timeMemory
566640SSRSFactories (JOI14_factories)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "factories.h" using namespace std; vector<vector<pair<int, int>>> E; void Init(int N, int A[], int B[], int D[]){ E = vector<vector<pair<int, int>>>(N); for (int i = 0; i < N - 1; i++){ E[A[i]].push_back(make_pair(D[i], B[i])); E[B[i]].push_back(make_pair(D[i], A[i])); } } long long Query(int S, int X[], int Y, int Y[]){ int N = E.size(); vector<long long> d(N, -1); priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq; for (int i = 0; i < S; i++){ pq.push(make_pair(0, X[i])); } while (!pq.empty()){ long long c = pq.top().first; int v = pq.top().second; pq.pop(); if (d[v] == -1){ d[v] = c; for (auto P : E[v]){ int w = P.second; if (d[w] == -1){ pq.push(make_pair(c + P.first, w)); } } } } long long ans = INF; for (int i = 0; i < T; i++){ ans = min(ans, d[Y[i]]); } return ans; }

Compilation message (stderr)

factories.cpp:12:44: error: conflicting declaration 'int* Y'
   12 | long long Query(int S, int X[], int Y, int Y[]){
      |                                        ~~~~^~~
factories.cpp:12:37: note: previous declaration as 'int Y'
   12 | long long Query(int S, int X[], int Y, int Y[]){
      |                                 ~~~~^
factories.cpp: In function 'long long int Query(int, int*, int)':
factories.cpp:33:19: error: 'INF' was not declared in this scope
   33 |   long long ans = INF;
      |                   ^~~
factories.cpp:34:23: error: 'T' was not declared in this scope
   34 |   for (int i = 0; i < T; i++){
      |                       ^
factories.cpp:35:23: error: invalid types 'int[int]' for array subscript
   35 |     ans = min(ans, d[Y[i]]);
      |                       ^