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>
#include"dreaming.h"
using namespace std;
const int MAX = 2e6 + 15;
const int INF = 0x3f3f3f3f;
#define fr first
#define sc second
bool seen[MAX];
vector<pair<int, int>> adj[MAX];
void dfs(int u){
seen[u] = true;
for(auto e : adj[u]){
int v = e.fr;
if(!seen[v]) dfs(v);
}
}
int travelTime(int n, int m, int L, int A[], int B[], int T[]){
int ret = 0, comp = 0;
for(int i = 0; i < m; i++){
int u = A[i], v = B[i], w = T[i];
adj[u].push_back({v, w});
adj[v].push_back({u, w});
ret += w;
}
for(int i = 0; i < n; i++){
if(seen[i]) continue;
seen[i] = true;
comp++;
dfs(i);
}
return (comp - 1) * L + ret;
}
# | 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... |