제출 #991100

#제출 시각아이디문제언어결과실행 시간메모리
991100stdfloatCrocodile's Underground City (IOI11_crocodile)C++17
46 / 100
138 ms262144 KiB
#include <bits/stdc++.h> #include "crocodile.h" using namespace std; #define ff first #define ss second #define pii pair<int, int> using ll = long long; vector<bool> vis; vector<int> u; vector<ll> v; vector<vector<pii>> E; void dfs(int x, int p = -1) { if (vis[x]) { v[x] = 0; return; } for (auto [i, w] : E[x]) if (i != p) dfs(i, x); u.clear(); for (auto [i, w] : E[x]) { if (i != p && v[i] != LLONG_MAX) u.push_back(v[i] + w); } sort(u.begin(), u.end()); if (1 < (int)u.size()) v[x] = u[1]; } int travel_plan(int n, int M, int R[][2], int L[], int K, int P[]) { E.assign(n, {}); for (int i = 0; i < M; i++) { E[R[i][0]].push_back({R[i][1], L[i]}); E[R[i][1]].push_back({R[i][0], L[i]}); } vis.assign(n, false); for (int i = 0; i < K; i++) vis[P[i]] = true; v.assign(n, LLONG_MAX); dfs(0); return v[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...