제출 #758965

#제출 시각아이디문제언어결과실행 시간메모리
758965Adrian_SoriagaVoting Cities (NOI22_votingcity)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pail; vector<ll> dij(vector<pail> adj[] , int start ,int target , int nodes){ ll INF = 1000000000000000; vector<ll> ans; vector<int> done(nodes,0); vector<ll> distance(nodes,INF); priority_queue<pail, vector<pail>, greater<pail>> pq; pq.push({0,start}); distance[start] = 0; while (!pq.empty()){ ll u = pq.top().second; pq.pop(); if (done[u]) continue; done[u] =1; for (auto x: adj[u]){ ll v = x.first , w = x.second; if (distance[v] > distance[u]+ w) distance[v] = distance[u]+w; pq.push({distance[v],v}); } } for (int i=0; i<n;i++) ans.push_back(distance[i]); return ans; } int main(){ ll n,e,k; cin>>n>>e>>k; int t; cin>>t; vector<pail> adj[n]; for (int i=0; i<e;i++){ ll a,b,w; cin>>a>>b>>w; adj[a].push_back({b,w}); //adj[b].push_back({a,w}); } int q,s; cin>>q>>s; vector<ll> check = dij(adj,t,s,n); if (check[s] ==1000000000000000 ) cout<<-1<<"\n"; else cout<<check[s]<<"\n"; //getting the dummy tickets; cin>>s>>s>>s>>s>>s; for (int i=1; i<q; i++){ int t_1,t_2,t_3,t_4,t_5; cin>>s>>t_1>>t_2>>t_3>>t_4>>t_5; if (check[s] ==1000000000000000 ) cout<<-1<<"\n"; else cout<<check[s]<<"\n"; } }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'std::vector<long long int> dij(std::vector<std::pair<long long int, long long int> >*, int, int, int)':
Main.cpp:24:21: error: 'n' was not declared in this scope
   24 |     for (int i=0; i<n;i++) ans.push_back(distance[i]);
      |                     ^