답안 #43724

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43724 2018-03-21T17:08:16 Z baactree 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
1176 ms 52204 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m;
vector<pair<int, int> > adj[100005];
priority_queue<ll> dist[100005];
ll ans[100005];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
	n = N; m = M;
	for (int i = 0; i < m; i++) {
		adj[R[i][0]].emplace_back(R[i][1], L[i]);
		adj[R[i][1]].emplace_back(R[i][0], L[i]);
	}
	priority_queue<pair<ll, int> > pq;
	memset(ans, 0x3f, sizeof(ans));
	for (int i = 0; i < K; i++) {
		dist[P[i]].push(0);
		dist[P[i]].push(0);
		pq.push({ 0, P[i] });
		ans[P[i]] = 0;
	}
	while (!pq.empty()) {
		ll cost = -pq.top().first;
		int now = pq.top().second;
		pq.pop();
		if (ans[now]< cost)continue;
		for (auto &e : adj[now]) {
			int there = e.first;
			int weight = e.second;
			dist[there].push(cost + weight);
			while (dist[there].size() > 2)dist[there].pop();
			if (dist[there].size() == 2 && dist[there].top() < ans[there]) {
				ans[there] = dist[there].top();
				pq.push({ -dist[there].top(),there });
			}
		}
	}
	return ans[0];
}


# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 6520 KB Output is correct
2 Correct 6 ms 6628 KB Output is correct
3 Correct 7 ms 6696 KB Output is correct
4 Correct 8 ms 6896 KB Output is correct
5 Correct 10 ms 7060 KB Output is correct
6 Correct 8 ms 7060 KB Output is correct
7 Correct 7 ms 7060 KB Output is correct
8 Correct 9 ms 7060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7060 KB Output is correct
2 Correct 6 ms 7060 KB Output is correct
3 Correct 7 ms 7060 KB Output is correct
4 Correct 15 ms 7128 KB Output is correct
5 Correct 10 ms 7256 KB Output is correct
6 Correct 7 ms 7256 KB Output is correct
7 Correct 9 ms 7256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 730 ms 45944 KB Output is correct
2 Correct 119 ms 45944 KB Output is correct
3 Correct 175 ms 45944 KB Output is correct
4 Correct 1176 ms 52204 KB Output is correct
5 Correct 375 ms 52204 KB Output is correct
6 Correct 91 ms 52204 KB Output is correct
7 Correct 410 ms 52204 KB Output is correct