답안 #954096

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954096 2024-03-27T09:24:42 Z 4QT0R 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
437 ms 60076 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>

struct edge{
	int to;
	int cost;
};

vector<edge> graph[100003];
pll odl[100003];
ll oo=1e18+1;

priority_queue<pll,vector<pll>,greater<pll>> pq;

void Dijkstra(){
	while(pq.size()){
		auto [d,v]=pq.top();
		pq.pop();
		if (odl[v].second<d)continue;
		for (auto u : graph[v]){
			if (d+u.cost<odl[u.to].first){
				if (odl[u.to].first!=odl[u.to].second && odl[u.to].first<oo){
					odl[u.to].second=odl[u.to].first;
					pq.push(make_pair(odl[u.to].second,u.to));
				}
				odl[u.to].first=d+u.cost;
			}
			else if (d+u.cost<odl[u.to].second){
				odl[u.to].second=d+u.cost;
				pq.push(make_pair(odl[u.to].second,u.to));
			}
		}
	}
}

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
	for (int i = 0; i<m; i++){
		graph[r[i][0]].push_back({r[i][1],l[i]});
		graph[r[i][1]].push_back({r[i][0],l[i]});
	}
	fill(odl,odl+n,make_pair(oo,oo));
	for (int i = 0; i<k; i++){
		pq.push({0,p[i]});
		odl[p[i]]={0,0};
	}
	Dijkstra();
	return odl[0].second;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6600 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6588 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6600 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6588 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 3 ms 8708 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 6 ms 8796 KB Output is correct
13 Correct 4 ms 9052 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6600 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6588 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 3 ms 8708 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 6 ms 8796 KB Output is correct
13 Correct 4 ms 9052 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 298 ms 55760 KB Output is correct
17 Correct 53 ms 17284 KB Output is correct
18 Correct 72 ms 18740 KB Output is correct
19 Correct 437 ms 60076 KB Output is correct
20 Correct 219 ms 47684 KB Output is correct
21 Correct 27 ms 14172 KB Output is correct
22 Correct 239 ms 44932 KB Output is correct