답안 #471877

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
471877 2021-09-11T11:04:01 Z dooompy 악어의 지하 도시 (IOI11_crocodile) C++17
0 / 100
1 ms 204 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int seen[100005];

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<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;

	
	for (int i = 0; i < K; i++) {
		pq.push({0, P[i]});
		seen[i] = 1;
	}
	
	while (!pq.empty()) {
		auto curdist = pq.top().first; 
		auto node = pq.top().second;
		pq.pop();
		
		if (!seen[node]) {
			seen[node] = 1;
			continue;
		}
		
		if (seen[node] == 2) continue;
		
		if (node == 0) {
			return curdist;
		}
		
		seen[node] = 2;
		
		for (auto a : adj[node]) {
			if (seen[a.first] != 2) {
				pq.push({curdist + a.second, a.first});
			}
		}
	}
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:12:38: warning: control reaches end of non-void function [-Wreturn-type]
   12 |  vector<vector<pair<int, int>>> adj(N);
      |                                      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -