# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
332764 | 2020-12-03T08:47:57 Z | CursedCode | Dreaming (IOI13_dreaming) | C++14 | 55 ms | 14700 KB |
#include "dreaming.h" #include <bits/stdc++.h> #define pb push_back #define mp make_pair using namespace std; vector<pair<int, int> > adj[100005]; int go[100005]; int cost[1000005] = {0}; int vis[1000005] = {0}; int n; int id = 0, max_path = 0; // grap bolgonii median max vector<int> median; void dfs(int u, int x, int path){ if(max_path <= path) { id = u; max_path = path; } vis[u] = 1; for(int i = 0; i < adj[u].size(); i++){ int v, e; v = adj[u][i].first; e = adj[u][i].second; if(v != x) { dfs(v, u, path + e); } } } void dfss(int u, int x){ if(max_path <= cost[u]) { id = u; max_path = cost[u]; } vis[u] = 1; go[u] = x; for(int i = 0; i < adj[u].size(); i++){ int v, e; v = adj[u][i].first; e = adj[u][i].second; if(v != x) { cost[v] = cost[u] + e; dfss(v, u); } } } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { n = N; memset(go, -1, sizeof(go)); for(int i = 0; i < M; i++){ adj[A[i]].pb(mp(B[i], T[i])); adj[B[i]].pb(mp(A[i], T[i])); } for(int i = 0; i < n; i++) if(vis[i] == 0){ id = 0; max_path = 0; dfs(i, -1, 0); max_path = 0; dfss(id, -1); int diameter = max_path; int u = id; int path = 1e9; while(u != -1){ path = min(path, max(diameter - cost[u], cost[u])); u = go[u]; } median.pb(path); } sort(median.begin(), median.end()); int sz = median.size(); int res = 0; res = max(res, median[sz - 1] + median[sz - 2] + L); if(sz > 2) res = max(res, median[sz - 2] + median[sz - 3] + 2 * L); return res; } #define MAX_N 100000 int A[MAX_N]; int B[MAX_N]; int T[MAX_N];
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 55 ms | 14700 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 55 ms | 14700 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 55 ms | 14700 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 7024 KB | Output is correct |
2 | Correct | 29 ms | 7020 KB | Output is correct |
3 | Correct | 32 ms | 6896 KB | Output is correct |
4 | Correct | 29 ms | 7032 KB | Output is correct |
5 | Correct | 27 ms | 7020 KB | Output is correct |
6 | Correct | 28 ms | 7408 KB | Output is correct |
7 | Correct | 28 ms | 7152 KB | Output is correct |
8 | Correct | 25 ms | 6896 KB | Output is correct |
9 | Correct | 28 ms | 6888 KB | Output is correct |
10 | Correct | 27 ms | 7016 KB | Output is correct |
11 | Correct | 2 ms | 3052 KB | Output is correct |
12 | Correct | 7 ms | 4328 KB | Output is correct |
13 | Correct | 7 ms | 4456 KB | Output is correct |
14 | Correct | 7 ms | 4328 KB | Output is correct |
15 | Correct | 7 ms | 4456 KB | Output is correct |
16 | Correct | 7 ms | 4328 KB | Output is correct |
17 | Correct | 6 ms | 4200 KB | Output is correct |
18 | Correct | 7 ms | 4456 KB | Output is correct |
19 | Correct | 7 ms | 4328 KB | Output is correct |
20 | Incorrect | 2 ms | 3052 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 55 ms | 14700 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 55 ms | 14700 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |