답안 #756637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
756637 2023-06-12T03:09:48 Z pavement 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
571 ms 72936 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

#define eb emplace_back
using ll = long long;
using ii = pair<int, int>;

ll fd[100005], sd[100005];
bool vis[100005];
vector<pair<int, ll> > adj[100005];
priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > pq, poss;

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]].eb(R[i][1], L[i]);
		adj[R[i][1]].eb(R[i][0], L[i]);
	}
	for (int i = 0; i < N; i++) {
		fd[i] = sd[i] = (ll)1e16;
	}
	for (int i = 0; i < K; i++) {
		fd[P[i]] = sd[P[i]] = 0;
		pq.emplace(0, P[i]);
	}
	while (!poss.empty() || !pq.empty()) {
		while (!pq.empty()) {
			auto [d, v] = pq.top();
			pq.pop();
			if (sd[v] != d) continue;
			assert(!vis[v]);
			vis[v] = 1;
			for (auto [u, w] : adj[v]) {
				ll c = d + w;
				if (c < sd[u]) {
					assert(!vis[u]);
					sd[u] = c;
					if (sd[u] < fd[u]) swap(fd[u], sd[u]);
					if (sd[u] != (ll)1e16) poss.emplace(sd[u], u);
				}
			}
		}
		while (!poss.empty() && vis[poss.top().second]) poss.pop();
		if (poss.empty()) break;
		pq.emplace(poss.top());
		poss.pop();
	}
	return sd[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 3 ms 3028 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2772 KB Output is correct
12 Correct 4 ms 3284 KB Output is correct
13 Correct 5 ms 3540 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 3 ms 3028 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2772 KB Output is correct
12 Correct 4 ms 3284 KB Output is correct
13 Correct 5 ms 3540 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2772 KB Output is correct
16 Correct 424 ms 66804 KB Output is correct
17 Correct 75 ms 14572 KB Output is correct
18 Correct 97 ms 16752 KB Output is correct
19 Correct 571 ms 72936 KB Output is correct
20 Correct 286 ms 55016 KB Output is correct
21 Correct 48 ms 8244 KB Output is correct
22 Correct 286 ms 49956 KB Output is correct