b1ackhand 2023. 10. 26. 10:00
const int INF = 1000000000;
int N, D, C;
vector<pii> graph[10002];
int dist[10002];
int a, b, c; 
vector <int> path[10002];
priority_queue <pair<int, int>> pq;
        
for (int i = 1; i <= N; i++)
	dist[i] = INF;

priority_queue<pair<int, int>> pq;
pq.push({ 0, C });
dist[C] = 0;

while (!pq.empty())
{
	int cost = -pq.top().first;
	int cur = pq.top().second;
	pq.pop();
    
    if (dist[cur] < cost)
		continue;

	for (int j = 0; j < graph[cur].size(); j++)
	{
		int next = graph[cur][j].first;
		int nCost = graph[cur][j].second;

		if (dist[next] > cost + nCost)
		{
			dist[next] = cost + nCost;
			pq.push(make_pair(-dist[next], next));
		}
	}
}