Submission #872126

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
8721262023-11-12 10:49:47dsyzCrocodile's Underground City (IOI11_crocodile)C++17
100 / 100
524 ms104888 KiB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
using ll = long long;
#define MAXN (100005)
vector<pair<ll,ll> > v[MAXN];
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > > pq;
ll secondbest[MAXN]; //second best distance
ll visited[MAXN]; //number of times node i is visited
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
for(ll i = 0;i < M;i++){
ll a = R[i][0];
ll b = R[i][1];
ll c = L[i];
v[a].push_back({c,b});
v[b].push_back({c,a});
}
memset(secondbest,-1,sizeof(secondbest));
for(ll i = 0;i < K;i++){
pq.push({0,P[i]});
visited[P[i]] = 2; //we only need to visit exit nodes once anyways so just set it to 2
}
while(!pq.empty()){
ll d = pq.top().first;
ll x = pq.top().second;
pq.pop();
visited[x]++;
if(visited[x] >= 2){ //if visited at least twice, we can choose the second best distance among all the distances
if(secondbest[x] != -1 && d >= secondbest[x]) continue; //worse than pre-existing second best distance so far
if(secondbest[x] == -1){
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...