제출 #1126076

#제출 시각아이디문제언어결과실행 시간메모리
1126076m_bezrutchka꿈 (IOI13_dreaming)C++20
0 / 100
17 ms1344 KiB
#include "dreaming.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; const int MAXN = 1e2 + 10; const int INF = 2e9 + 10; vector<pii> adj[MAXN]; int comp[MAXN]; bool mrk[MAXN]; int dist[MAXN][MAXN]; int max_dist[MAXN]; int n; void dfs(int s, int v) { mrk[v] = true; for (auto [w, c]: adj[v]) { if (mrk[w]) continue; dist[s][w] = dist[s][v] + c; dfs(s, w); } } void build_dist(int v) { for (int i = 0; i < n; i++) { dist[v][i] = -INF; mrk[i] = false; } dist[v][v] = 0; dfs(v, v); for (int i = 0; i < n; i++) { max_dist[v] = max(max_dist[v], dist[v][i]); } } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { // subtask 3 assert(M == N - 2); n = N; for (int i = 0; i < M; i++) { adj[A[i]].push_back({B[i], T[i]}); adj[B[i]].push_back({A[i], T[i]}); } for (int i = 0; i < n; i++) { build_dist(i); } int resp = 2e9 + 10; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (dist[i][j] != -INF) continue; resp = min(resp, max_dist[i] + max_dist[j] + L); } } return resp; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...