Submission #672599

#TimeUsernameProblemLanguageResultExecution timeMemory
672599Hacv16Dreaming (IOI13_dreaming)C++17
0 / 100
58 ms52300 KiB
#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 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...