제출 #1240996

#제출 시각아이디문제언어결과실행 시간메모리
1240996guanexCrocodile's Underground City (IOI11_crocodile)C++20
46 / 100
2 ms1092 KiB
#include "crocodile.h" #include<bits/stdc++.h> using namespace std; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { vector<vector<pair<long long, long long>>> ed(N); for(long long i = 0; i < M; ++i){ ed[R[i][0]].push_back({R[i][1], L[i]}); ed[R[i][1]].push_back({R[i][0], L[i]}); } priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> pq; vector<pair<long long, long long>> paths(N, make_pair(1e16, 1e16)); long long dist[N]; for(long long i = 0; i < N; ++i){ dist[i] = 1e16; } for(int i = 0; i < K; ++i){ dist[P[i]] = 0; pq.push({0, P[i]}); } while(!pq.empty()){ long long no = pq.top().second; long long dis = pq.top().first; pq.pop(); if(paths[no].second < dis){ continue; } //cout << no << " " << dis << endl; for(auto e:ed[no]){ if(dis + e.second < paths[e.first].first){ paths[e.first].second = paths[e.first].first; paths[e.first].first = dis + e.second; pq.push({paths[e.first].second, e.first}); }else if(dis + e.second < paths[e.first].second){ paths[e.first].second = dis + e.second; pq.push({paths[e.first].second, e.first}); } } } return paths[0].second; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...