# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
210534 | Dan13llljws | Dreaming (IOI13_dreaming) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int dist[100001], pre[100001]; bool vis[100001];
int travelTime(int N, int M, int L, int A[], int B[], int T[]){
int maxDiameter = 0;
vector<int> radius;
vector<pair<int, int>> adj[N];
for (int i = 0; i < M; i++){
adj[A[i]].push_back(make_pair(T[i], B[i]));
adj[B[i]].push_back(make_pair(T[i], A[i]));
}
for (int i = 0; i < N; i++){
if (!vis[i]){
int maxd = 0, far = i, cur;
queue<pair<int, int>> q;
q.push(make_pair(i, 0));
vector<int> clean;
vis[i] = 1;
clean.push_back(i);
while(!q.empty()){
int p = q.front().first, d = q.front().second; q.pop();
if (d > maxd){
maxd = d;
far = p;
}
for (auto v : adj[p]){
if (!vis[v.second]){
vis[v.second] = 1;
clean.push_back(v.second);
q.push(make_pair(v.second, v.first + d));