답안 #672274

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
672274 2022-12-15T10:12:55 Z Hacv16 악어의 지하 도시 (IOI11_crocodile) C++17
0 / 100
27 ms 47252 KB
#include<bits/stdc++.h>
#include "crocodile.h"
using namespace std;

typedef long long ll;

const int MAX = 2e6 + 15;
const ll INF = 5e18 + 50;

#define fr first
#define sc second

ll dist[MAX][2], ans;
bool seen[MAX];
vector<pair<ll, ll>> adj[MAX];

int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]){
	for(int i = 0; i < m; i++){
		ll u = R[i][0], v = R[i][1], w = L[i];

		adj[u].push_back({v, w});
		adj[v].push_back({u, w});
	}

	for(int i = 0; i < n; i++)
		dist[i][0] = dist[i][1] = INF;

	priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q;

	for(int i = 0; i < k; i++){
		dist[P[i]][0] = dist[P[i]][1] = 0;
		q.push({0, P[i]});
	}

	while(q.size()){
		ll u = q.top().sc; q.pop();

		if(seen[u]) continue;

		seen[u] = true;

		for(auto e : adj[u]){
			ll v = e.fr, w = e.sc;

			if(dist[u][1] + w < dist[v][0]){
				swap(dist[v][1], dist[v][0]);
				dist[v][0] = dist[u][1] + w;
				q.push({dist[v][0], v});

			}else if(dist[u][1] + w < dist[v][1]){
				dist[v][1] = dist[u][1] + w;
				q.push({dist[v][1], v});
			}
		}
	}

	return dist[0][1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 47248 KB Output is correct
2 Incorrect 27 ms 47252 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 47248 KB Output is correct
2 Incorrect 27 ms 47252 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 47248 KB Output is correct
2 Incorrect 27 ms 47252 KB Output isn't correct
3 Halted 0 ms 0 KB -