Submission #104496

#TimeUsernameProblemLanguageResultExecution timeMemory
104496dfistricCrocodile's Underground City (IOI11_crocodile)C++14
46 / 100
20 ms2816 KiB
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define ll long long #define X first #define Y second using namespace std; const int MAXN = 100100; ll dist[MAXN]; ll inf = (1LL << 60); vector <pair <int, int> > ve[MAXN]; int n, m; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { n = N, m = M; REP(i, n) { int a = R[i][0], b = R[i][1]; ll c = L[i]; ve[a].push_back({b, c}); ve[b].push_back({a, c}); } REP(i, n) dist[i] = inf; REP(i, K) dist[P[i]] = 0; REP(t, 2 * n) { REP(x, n) { ll a = inf, b = inf; for (auto tr : ve[x]) { int y = tr.X; ll d = tr.Y; if (dist[y] + d < b) b = dist[y] + d; if (a > b) swap(a, b); } if (dist[x] > b) dist[x] = b; } } return dist[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...