| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1317960 | discontinuous | Dreaming (IOI13_dreaming) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "dreaming.h"
using namespace std;
#define pb push_back
#define int long long
const int MOD = 1e9 + 7;
const int INF = 1e15;
const int N = 1e6;
int n, m, k, a, b, c, d, h, l, r, q, u, v, x, y;
vector<int> arr(N);
vector<int> adj[N];
vector<int> vis(N);
vector<int> par(N);
map<pair<int, int>, int> weight;
int maxdist;
void dfs(int node, int dist) {
vis[node] = 1;
if(dist > maxdist) {
maxdist = dist;
h = node;
}
for(auto j : adj[node]) {
if(!vis[j]) {
par[j] = node;
dfs(j, dist+weight[{node, j}]);
}
}
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
for(int i = 0; i<M; i++) {
adj[A[i]].pb(B[i]);
adj[B[i]].pb(A[i]);
weight[{A[i], B[i]}] = c;
weight[{B[i], A[i]}] = c;
}
vector<int> all;
for(int i = 0; i<N; i++) {
if(!vis[i]) {
h = i;
maxdist = 0;
dfs(i, 0);
for(int j = 0; j<N; j++) {
par[j] = 0;
vis[j] = 0;
}
maxdist = 0;
dfs(h, 0);
all.pb(maxdist);
}
}
sort(all.rbegin(), all.rend());
// for(auto j : all) cout << j << " ";
return all[0] + all[1];
}
// int32_t main() {
// ios::sync_with_stdio(false);
// cout.tie(0); cin.tie(0);
// cin >> n >> m >> l;
// cout << travelTime(n, m, l);
// return 0;
// }
