답안 #1004666

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1004666 2024-06-21T12:00:14 Z vjudge3 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
287 ms 63432 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
 
vector<pair<int, int>> g[100005];
int di[100005][2];
bool vis[100005];
const int inf = 2e9;
 
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
	for (int i = 0; i < N; i++) di[i][0] = di[i][1] = inf;
	for (int i = 0; i < M; i++) {
		g[R[i][0]].push_back({R[i][1], L[i]});
		g[R[i][1]].push_back({R[i][0], L[i]});
	}
	using T = pair<int, int>;
	priority_queue<T, vector<T>, greater<T>> pq;
	for (int i = 0; i < K; i++) {
		pq.push({0, P[i]});
		di[P[i]][0] = di[P[i]][1] = 0;
	}
	while (!pq.empty()) {
		auto [d, u] = pq.top();
		pq.pop();
		if (di[u][1] != d) continue;
		if (vis[u]) continue;
		vis[u] = true;
		for (auto& [v, w] : g[u]) {
			if (d+w <= di[v][0]) {
				di[v][1] = di[v][0];
				di[v][0] = d+w;
				pq.push({di[v][1], v});
			} else if (d+w < di[v][1]) {
				di[v][1] = d+w;
				pq.push({di[v][1], v});
			}
		}
	}
	return di[0][1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 2 ms 2908 KB Output is correct
5 Correct 2 ms 2904 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
7 Correct 1 ms 2908 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 2 ms 2908 KB Output is correct
5 Correct 2 ms 2904 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
7 Correct 1 ms 2908 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 2 ms 2860 KB Output is correct
12 Correct 3 ms 3164 KB Output is correct
13 Correct 3 ms 3164 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 2 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 2 ms 2908 KB Output is correct
5 Correct 2 ms 2904 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
7 Correct 1 ms 2908 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 2 ms 2860 KB Output is correct
12 Correct 3 ms 3164 KB Output is correct
13 Correct 3 ms 3164 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 2 ms 2908 KB Output is correct
16 Correct 233 ms 58224 KB Output is correct
17 Correct 64 ms 15124 KB Output is correct
18 Correct 64 ms 16488 KB Output is correct
19 Correct 287 ms 63432 KB Output is correct
20 Correct 163 ms 49744 KB Output is correct
21 Correct 25 ms 8144 KB Output is correct
22 Correct 180 ms 46420 KB Output is correct