답안 #367266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
367266 2021-02-16T18:11:18 Z wind_reaper 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "crocodile.h"

using namespace std;

const int INF = 1e9 + 1;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
	vector<vector<pair<int, int>>> adj(N);
	for(int i = 0; i < M; i++){
		adj[R[i][0]].push_back({R[i][1], L[i]});
		adj[R[i][1]].push_back({R[i][0], L[i]});
	}

	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
	vector<array<int, 2>> d(N, {INF, INF});
	for(int i = 0; i < K; i++){
		d[i] = {0, 0};
		pq.push({0, i});
	}

	while(!pq.empty()){
		auto[dv, node] = pq.top();
		pq.pop();

		if(dv > d[i][1]) continue;
		for(auto& [v, l] : adj[node]){
			int nx = dv + l;
			if(nx > d[v][1]) continue;
			d[v][1] = nx;
			if(d[v][1] < d[v][0]) swap(d[v][1], d[v][0]);
			pq.push({nx, v});
		}
	}

	return (d[0][0] == INF ? -1 : d[0][0]);
}
/*int32_t main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	
	return 0; 
}*/
/*
implement something equivalent to a multi source dijkstra
*/

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:25:13: error: 'i' was not declared in this scope
   25 |   if(dv > d[i][1]) continue;
      |             ^