답안 #169458

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169458 2019-12-20T13:30:45 Z Shafin666 악어의 지하 도시 (IOI11_crocodile) C++14
0 / 100
6 ms 5112 KB
#include "crocodile.h"
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<ll, ll>
#define nyan "(=^・ω・^=)"
#define read_input         freopen("in.txt","r", stdin)
#define print_output       freopen("out.txt","w", stdout)
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 2e5+10;
int dist[maxn], visited[maxn];
vector<pii> adj[maxn];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	for(int i = 0; i < M; i++) {
		adj[R[i][0]].pb({R[i][1], L[i]});
		adj[R[i][1]].pb({R[i][0], L[i]});
	}

	for(int i = 0; i < N; i++) dist[i] = 1e9+7;

	multiset<pii> s;
	s.insert({0, 0});
	dist[0] = 0;

	while(!s.empty()) {
		pii p = *s.begin();
		s.erase(s.begin());

		int u = p.second;
		if(visited[u]) continue;
		visited[u] = 1;

		int mndist = 1e9+7, ver = -1;
		for(auto p : adj[u]) {
			int v = p.first, w = p.second;
			if(dist[u] + w < dist[v]) {
				if(dist[u] + w < mndist)
					mndist = dist[u] + w, ver = v;
			}
		}

		for(auto p : adj[u]) {
			int v = p.first, w = p.second;
			if(v == ver) continue;
			if(dist[u] + w < dist[v]) {
				dist[v] = dist[u] + w;
				s.insert({dist[v], v});
			}
		}
	}

	int ret = 1e9+7;
	for(int i = 0; i < K; i++)
		ret = min(ret, dist[P[i]]);


  	return ret;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4988 KB Output is correct
2 Incorrect 6 ms 5112 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4988 KB Output is correct
2 Incorrect 6 ms 5112 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4988 KB Output is correct
2 Incorrect 6 ms 5112 KB Output isn't correct
3 Halted 0 ms 0 KB -