답안 #756622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
756622 2023-06-12T02:07:53 Z siewjh 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
482 ms 45240 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int inf = 1e9 + 7;
vector<pair<int, int>> adj[MAXN];
int dist[MAXN], dist1[MAXN], vis[MAXN];
bool isexit[MAXN];

int travel_plan(int nodes, int edges, int elist[][2], int elen[], int exits, int exarr[]){
	for (int i = 0; i < edges; i++){
		int a = elist[i][0], b = elist[i][1], d = elen[i];
		adj[a].push_back({b, d});
		adj[b].push_back({a, d});
	}
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
	for (int i = 0; i < nodes; i++) dist[i] = dist1[i] = inf;
	for (int i = 0; i < exits; i++){
		dist[exarr[i]] = dist1[exarr[i]] = 0;
		pq.push({0, exarr[i]});
		vis[exarr[i]] = 1;
	}
	while (!pq.empty()){
		int d = pq.top().first, x = pq.top().second; pq.pop();
		if (d > dist1[x]) continue;
		if (vis[x] > 1) continue;
		if (vis[x] == 1){
			for (auto nxt : adj[x]){
				int nn = nxt.first, nd = nxt.second;
				if (d + nd < dist[nn]){
					dist1[nn] = dist[nn];
					dist[nn] = d + nd;
					pq.push({dist[nn], nn});
				}
				else if (d + nd < dist1[nn]){
					dist1[nn] = d + nd;
					pq.push({dist1[nn], nn});
				}
			}
		}
		vis[x]++;
	}
	return dist1[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 2 ms 2644 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 3 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 2 ms 2644 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 2900 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2772 KB Output is correct
12 Correct 5 ms 3028 KB Output is correct
13 Correct 4 ms 3028 KB Output is correct
14 Correct 1 ms 2644 KB Output is correct
15 Correct 3 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 2 ms 2644 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 2900 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2772 KB Output is correct
12 Correct 5 ms 3028 KB Output is correct
13 Correct 4 ms 3028 KB Output is correct
14 Correct 1 ms 2644 KB Output is correct
15 Correct 3 ms 2688 KB Output is correct
16 Correct 376 ms 42396 KB Output is correct
17 Correct 65 ms 10828 KB Output is correct
18 Correct 85 ms 12188 KB Output is correct
19 Correct 482 ms 45240 KB Output is correct
20 Correct 232 ms 36664 KB Output is correct
21 Correct 32 ms 6388 KB Output is correct
22 Correct 258 ms 31916 KB Output is correct