Submission #554672

#TimeUsernameProblemLanguageResultExecution timeMemory
554672kevinxiehk악어의 지하 도시 (IOI11_crocodile)C++17
100 / 100
637 ms66932 KiB
#include "crocodile.h" #include <bits/stdc++.h> #define mp make_pair #define pb emplace_back #define fi first #define se second using namespace std; vector<pair<int, int>> conn[100005]; int dist[100005]; int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){ for(int i = 0; i < n; i++) dist[i] = -1; priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> dij; for(int i = 0; i < k; i++) { dist[p[i]] = 0; dij.push(mp(0, p[i])); } for(int i = 0; i < m; i++) { conn[r[i][0]].pb(mp(r[i][1], l[i])); conn[r[i][1]].pb(mp(r[i][0], l[i])); } while(!dij.empty()) { pair<int, int> now = dij.top(); dij.pop(); if(dist[now.se] > 0 && dist[now.se] <= now.fi) continue; if(dist[now.se] == -1) { dist[now.se] = -2; continue; } dist[now.se] = now.fi; for(auto x: conn[now.se]) { if(dist[x.fi] < 0 || dist[x.fi] > now.fi + x.se) { dij.push(mp(x.se + now.fi, x.fi)); } } } return dist[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...