답안 #76879

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
76879 2018-09-19T02:07:41 Z shoemakerjo 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
832 ms 73176 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define pii pair<ll, int>

#define maxn 100010
const ll bil = 2000000000LL;
vector<vector<pii>> adj(maxn);
ll dist[maxn][2];
priority_queue<pii, vector<pii>, greater<pii>> pq;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	for (int i = 0; i < N; i++) {
		dist[i][0] = dist[i][1] = bil;
	}
	int v;
	for (int i = 0; i < K; i++) {
		v = P[i];
		dist[v][0] = dist[v][1] = 0;
		pq.push(pii(0, v));
	}

	for (int i = 0; i < M; i++) {
		adj[R[i][0]].push_back(pii(R[i][1], L[i]));
		adj[R[i][1]].push_back(pii(R[i][0], L[i]));
	}

	ll d;
	while (!pq.empty()) {
		d = pq.top().first;
		v = pq.top().second;
		// cout << v << " : " << d << endl;
		pq.pop();
		if (dist[v][1] < d) continue;

		for (pii vv : adj[v]) {
			ll odist = dist[vv.first][1];
			if (d + vv.second < dist[vv.first][0]) {
				dist[vv.first][1] = dist[vv.first][0];
				dist[vv.first][0] = d + vv.second;
				if (dist[vv.first][1] != odist) 
					pq.push(pii(dist[vv.first][1], vv.first));
			}
			else if (d + vv.second < dist[vv.first][1]) {
				dist[vv.first][1] = d + vv.second;
				if (dist[vv.first][1] != odist) 
					pq.push(pii(dist[vv.first][1], vv.first));
			}
		}

	}


	return dist[0][1];
}


# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2804 KB Output is correct
3 Correct 4 ms 2856 KB Output is correct
4 Correct 4 ms 2912 KB Output is correct
5 Correct 4 ms 2972 KB Output is correct
6 Correct 4 ms 3100 KB Output is correct
7 Correct 5 ms 3100 KB Output is correct
8 Correct 4 ms 3100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2804 KB Output is correct
3 Correct 4 ms 2856 KB Output is correct
4 Correct 4 ms 2912 KB Output is correct
5 Correct 4 ms 2972 KB Output is correct
6 Correct 4 ms 3100 KB Output is correct
7 Correct 5 ms 3100 KB Output is correct
8 Correct 4 ms 3100 KB Output is correct
9 Correct 7 ms 3244 KB Output is correct
10 Correct 4 ms 3244 KB Output is correct
11 Correct 5 ms 3244 KB Output is correct
12 Correct 9 ms 3504 KB Output is correct
13 Correct 7 ms 3692 KB Output is correct
14 Correct 4 ms 3692 KB Output is correct
15 Correct 6 ms 3692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2804 KB Output is correct
3 Correct 4 ms 2856 KB Output is correct
4 Correct 4 ms 2912 KB Output is correct
5 Correct 4 ms 2972 KB Output is correct
6 Correct 4 ms 3100 KB Output is correct
7 Correct 5 ms 3100 KB Output is correct
8 Correct 4 ms 3100 KB Output is correct
9 Correct 7 ms 3244 KB Output is correct
10 Correct 4 ms 3244 KB Output is correct
11 Correct 5 ms 3244 KB Output is correct
12 Correct 9 ms 3504 KB Output is correct
13 Correct 7 ms 3692 KB Output is correct
14 Correct 4 ms 3692 KB Output is correct
15 Correct 6 ms 3692 KB Output is correct
16 Correct 637 ms 66908 KB Output is correct
17 Correct 99 ms 66908 KB Output is correct
18 Correct 133 ms 66908 KB Output is correct
19 Correct 832 ms 73176 KB Output is correct
20 Correct 393 ms 73176 KB Output is correct
21 Correct 48 ms 73176 KB Output is correct
22 Correct 397 ms 73176 KB Output is correct