답안 #43723

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43723 2018-03-21T17:02:52 Z baactree 악어의 지하 도시 (IOI11_crocodile) C++14
89 / 100
1000 ms 104360 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];
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;
	for (int i = 0; i < K; i++) {
		dist[P[i]].push(0);
		dist[P[i]].push(0);
		pq.push({ 0, P[i] });
	}
	while (!pq.empty()) {
		ll cost = -pq.top().first;
		int now = pq.top().second;
		pq.pop();
		if (dist[now].top() < cost)continue;
		for (auto &e : adj[now]) {
			int there = e.first;
			int weight = e.second;
			if (dist[there].size() < 2) {
				dist[there].push(cost + weight);
				if (dist[there].size() == 2)
					pq.push({ -dist[there].top(),there });
			}
			else {
				if (dist[there].top() > cost + weight) {
					dist[there].pop();
					dist[there].push(cost + weight);
					pq.push({ -dist[there].top(), there });
				}
			}
		}
	}
	return dist[0].top();
}


# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 5880 KB Output is correct
2 Correct 6 ms 5880 KB Output is correct
3 Correct 7 ms 5948 KB Output is correct
4 Correct 9 ms 5980 KB Output is correct
5 Correct 7 ms 6140 KB Output is correct
6 Correct 7 ms 6140 KB Output is correct
7 Correct 7 ms 6208 KB Output is correct
8 Correct 9 ms 6352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 6616 KB Output is correct
2 Correct 6 ms 6616 KB Output is correct
3 Correct 7 ms 6616 KB Output is correct
4 Correct 11 ms 6860 KB Output is correct
5 Correct 9 ms 6976 KB Output is correct
6 Correct 6 ms 6976 KB Output is correct
7 Correct 7 ms 6976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 650 ms 61848 KB Output is correct
2 Correct 113 ms 61848 KB Output is correct
3 Correct 153 ms 61848 KB Output is correct
4 Correct 1000 ms 89668 KB Output is correct
5 Correct 365 ms 92960 KB Output is correct
6 Correct 60 ms 92960 KB Output is correct
7 Incorrect 387 ms 104360 KB Output isn't correct