제출 #566640

#제출 시각아이디문제언어결과실행 시간메모리
566640SSRS공장들 (JOI14_factories)C++14
컴파일 에러
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; }

컴파일 시 표준 에러 (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]]);
      |                       ^