이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"dreaming.h"
//#include"grader.c"
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
vector<pair<int,int>>g[100005];
int path[105],mn,idd;
bool vis[105];
void dfs(int v,int p,int depth,int glob){
path[glob]=max(depth,path[glob]);
mn=max(mn,depth);
for(auto to:g[v])
if(to.fr!=p)
dfs(to.fr,v,depth+to.sc,glob);
}
void go(int v,int p){
vis[v]=1;
mn=min(mn,path[v]);
if(path[v]<mn){
mn=path[v];
idd=v;
}
for(auto to:g[v])
if(to.fr!=p)
go(to.fr,v);
}
int travelTime(int n,int m,int l,int x[],int y[],int z[]){
int i;
for(i=0;i<m;i++){
g[x[i]].push_back({y[i],z[i]});
g[y[i]].push_back({x[i],z[i]});
}
for(i=0;i<n;i++)dfs(i,i,0,i);
stack<int>st;
for(i=0;i<n;i++)if(!vis[i]){
mn=2e9;
go(i,i);
st.push(idd);
}
int xx=st.top();
st.pop();
int yy=st.top();
st.pop();
g[xx].push_back({yy,0});
g[yy].push_back({xx,0});
mn=0;
for(i=0;i<n;i++)dfs(i,i,0,i);
return mn;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |