# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
17156 | 2015-11-07T08:50:46 Z | murat | Dreaming (IOI13_dreaming) | C++ | 118 ms | 42744 KB |
#include<bits/stdc++.h> #include "dreaming.h" using namespace std; #define foreach(it, x) for(type(x) it = x.begin(); it != x.end(); it++) #define type(x) __typeof(x.begin()) #define pb push_back #define mp make_pair #define nd second #define st first const int N = 1e6 + 5; const int inf = 1e9 + 5; typedef pair< int , int > pii; static int n, m, x, y, z, val[N], h[N]; static vector< pii > v[N]; pii dfs(int node, int root = 0) { pii tt = mp(0, node); foreach(it, v[node]) if(it->st != root) { pii temp = dfs(it->st, node); temp.st += it->nd; tt = max(tt, temp); } return tt; } static void dfs2(int node, int root = 0, int dist = 0) { val[node] = max(val[node], dist); foreach(it, v[node]) if(it->st != root) dfs2(it->st, node, dist + it->nd); } static int take(int node, int root = 0) { int nnn = node; h[node] = 1; foreach(it, v[node]) if(it->st != root) { int ttt = take(it->st, node); if(val[ttt] < val[nnn]) nnn = ttt; } return nnn; } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { n = N; for(int i = 0; i < N; i++) v[i].clear(); for(int i = 0; i < M; i++) { int x = A[i], y = B[i], z = T[i]; v[x].pb(mp(y, z)); v[y].pb(mp(x, z)); } vector< pii > gg; gg.clear(); memset(val, 0, sizeof val); memset(h, 0, sizeof h); for(int i = 0; i < N; i++) { if(!h[i]) { int x = dfs(i).nd, y = dfs(x).nd; dfs2(x); dfs2(y); int nnn = take(i); gg.pb(mp(val[nnn], nnn)); } } sort(gg.begin(), gg.end(), greater< pii >()); for(int i = 1; i < gg.size(); i++) { v[gg[i].nd].pb(mp(gg[0].nd, L)); v[gg[0].nd].pb(mp(gg[i].nd, L)); } int x = dfs(0).nd, ans = dfs(x).st; return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 107 ms | 42616 KB | Output is correct |
2 | Correct | 118 ms | 42744 KB | Output is correct |
3 | Correct | 84 ms | 38952 KB | Output is correct |
4 | Correct | 37 ms | 33272 KB | Output is correct |
5 | Correct | 38 ms | 32504 KB | Output is correct |
6 | Correct | 49 ms | 34224 KB | Output is correct |
7 | Correct | 29 ms | 31736 KB | Output is correct |
8 | Correct | 63 ms | 35264 KB | Output is correct |
9 | Correct | 80 ms | 36996 KB | Output is correct |
10 | Correct | 28 ms | 31744 KB | Output is correct |
11 | Correct | 99 ms | 38364 KB | Output is correct |
12 | Correct | 112 ms | 40444 KB | Output is correct |
13 | Correct | 28 ms | 31736 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 107 ms | 42616 KB | Output is correct |
2 | Correct | 118 ms | 42744 KB | Output is correct |
3 | Correct | 84 ms | 38952 KB | Output is correct |
4 | Correct | 37 ms | 33272 KB | Output is correct |
5 | Correct | 38 ms | 32504 KB | Output is correct |
6 | Correct | 49 ms | 34224 KB | Output is correct |
7 | Correct | 29 ms | 31736 KB | Output is correct |
8 | Correct | 63 ms | 35264 KB | Output is correct |
9 | Correct | 80 ms | 36996 KB | Output is correct |
10 | Correct | 28 ms | 31744 KB | Output is correct |
11 | Correct | 99 ms | 38364 KB | Output is correct |
12 | Correct | 112 ms | 40444 KB | Output is correct |
13 | Correct | 28 ms | 31736 KB | Output is correct |
14 | Correct | 29 ms | 31616 KB | Output is correct |
15 | Correct | 28 ms | 31744 KB | Output is correct |
16 | Correct | 28 ms | 31616 KB | Output is correct |
17 | Correct | 29 ms | 31616 KB | Output is correct |
18 | Correct | 27 ms | 31608 KB | Output is correct |
19 | Correct | 28 ms | 31608 KB | Output is correct |
20 | Correct | 28 ms | 31744 KB | Output is correct |
21 | Correct | 29 ms | 31612 KB | Output is correct |
22 | Correct | 29 ms | 31612 KB | Output is correct |
23 | Correct | 28 ms | 31616 KB | Output is correct |
24 | Correct | 29 ms | 31792 KB | Output is correct |
25 | Correct | 28 ms | 31580 KB | Output is correct |
26 | Correct | 28 ms | 31616 KB | Output is correct |
27 | Correct | 28 ms | 31708 KB | Output is correct |
28 | Incorrect | 27 ms | 31616 KB | Output isn't correct |
29 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 107 ms | 42616 KB | Output is correct |
2 | Correct | 118 ms | 42744 KB | Output is correct |
3 | Correct | 84 ms | 38952 KB | Output is correct |
4 | Correct | 37 ms | 33272 KB | Output is correct |
5 | Correct | 38 ms | 32504 KB | Output is correct |
6 | Correct | 49 ms | 34224 KB | Output is correct |
7 | Correct | 29 ms | 31736 KB | Output is correct |
8 | Correct | 63 ms | 35264 KB | Output is correct |
9 | Correct | 80 ms | 36996 KB | Output is correct |
10 | Correct | 28 ms | 31744 KB | Output is correct |
11 | Correct | 99 ms | 38364 KB | Output is correct |
12 | Correct | 112 ms | 40444 KB | Output is correct |
13 | Correct | 28 ms | 31736 KB | Output is correct |
14 | Correct | 29 ms | 31616 KB | Output is correct |
15 | Correct | 28 ms | 31744 KB | Output is correct |
16 | Correct | 28 ms | 31616 KB | Output is correct |
17 | Correct | 29 ms | 31616 KB | Output is correct |
18 | Correct | 27 ms | 31608 KB | Output is correct |
19 | Correct | 28 ms | 31608 KB | Output is correct |
20 | Correct | 28 ms | 31744 KB | Output is correct |
21 | Correct | 29 ms | 31612 KB | Output is correct |
22 | Correct | 29 ms | 31612 KB | Output is correct |
23 | Correct | 28 ms | 31616 KB | Output is correct |
24 | Correct | 29 ms | 31792 KB | Output is correct |
25 | Correct | 28 ms | 31580 KB | Output is correct |
26 | Correct | 28 ms | 31616 KB | Output is correct |
27 | Correct | 28 ms | 31708 KB | Output is correct |
28 | Incorrect | 27 ms | 31616 KB | Output isn't correct |
29 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 70 ms | 35868 KB | Output is correct |
2 | Correct | 67 ms | 35952 KB | Output is correct |
3 | Correct | 75 ms | 35880 KB | Output is correct |
4 | Correct | 77 ms | 35996 KB | Output is correct |
5 | Correct | 68 ms | 35880 KB | Output is correct |
6 | Correct | 80 ms | 36716 KB | Output is correct |
7 | Correct | 70 ms | 36092 KB | Output is correct |
8 | Correct | 71 ms | 35896 KB | Output is correct |
9 | Correct | 65 ms | 35848 KB | Output is correct |
10 | Correct | 81 ms | 36064 KB | Output is correct |
11 | Correct | 27 ms | 31736 KB | Output is correct |
12 | Correct | 46 ms | 36332 KB | Output is correct |
13 | Correct | 46 ms | 36332 KB | Output is correct |
14 | Correct | 48 ms | 36332 KB | Output is correct |
15 | Correct | 47 ms | 36304 KB | Output is correct |
16 | Correct | 45 ms | 36336 KB | Output is correct |
17 | Correct | 46 ms | 36340 KB | Output is correct |
18 | Correct | 46 ms | 36340 KB | Output is correct |
19 | Correct | 47 ms | 36332 KB | Output is correct |
20 | Correct | 28 ms | 31660 KB | Output is correct |
21 | Incorrect | 29 ms | 31608 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 107 ms | 42616 KB | Output is correct |
2 | Correct | 118 ms | 42744 KB | Output is correct |
3 | Correct | 84 ms | 38952 KB | Output is correct |
4 | Correct | 37 ms | 33272 KB | Output is correct |
5 | Correct | 38 ms | 32504 KB | Output is correct |
6 | Correct | 49 ms | 34224 KB | Output is correct |
7 | Correct | 29 ms | 31736 KB | Output is correct |
8 | Correct | 63 ms | 35264 KB | Output is correct |
9 | Correct | 80 ms | 36996 KB | Output is correct |
10 | Correct | 28 ms | 31744 KB | Output is correct |
11 | Correct | 99 ms | 38364 KB | Output is correct |
12 | Correct | 112 ms | 40444 KB | Output is correct |
13 | Correct | 28 ms | 31736 KB | Output is correct |
14 | Correct | 29 ms | 31736 KB | Output is correct |
15 | Correct | 29 ms | 31744 KB | Output is correct |
16 | Correct | 30 ms | 31744 KB | Output is correct |
17 | Correct | 28 ms | 31744 KB | Output is correct |
18 | Correct | 29 ms | 31736 KB | Output is correct |
19 | Correct | 29 ms | 31864 KB | Output is correct |
20 | Correct | 28 ms | 31744 KB | Output is correct |
21 | Correct | 29 ms | 31744 KB | Output is correct |
22 | Correct | 31 ms | 31744 KB | Output is correct |
23 | Correct | 29 ms | 31608 KB | Output is correct |
24 | Correct | 27 ms | 31616 KB | Output is correct |
25 | Correct | 27 ms | 31572 KB | Output is correct |
26 | Correct | 27 ms | 31616 KB | Output is correct |
27 | Correct | 28 ms | 31608 KB | Output is correct |
28 | Correct | 27 ms | 31616 KB | Output is correct |
29 | Correct | 28 ms | 31612 KB | Output is correct |
30 | Correct | 28 ms | 31616 KB | Output is correct |
31 | Correct | 28 ms | 31608 KB | Output is correct |
32 | Correct | 30 ms | 31616 KB | Output is correct |
33 | Correct | 28 ms | 31616 KB | Output is correct |
34 | Correct | 29 ms | 31608 KB | Output is correct |
35 | Correct | 28 ms | 31608 KB | Output is correct |
36 | Correct | 29 ms | 31736 KB | Output is correct |
37 | Correct | 29 ms | 31608 KB | Output is correct |
38 | Correct | 29 ms | 31608 KB | Output is correct |
39 | Correct | 29 ms | 31736 KB | Output is correct |
40 | Correct | 29 ms | 31608 KB | Output is correct |
41 | Incorrect | 32 ms | 31616 KB | Output isn't correct |
42 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 107 ms | 42616 KB | Output is correct |
2 | Correct | 118 ms | 42744 KB | Output is correct |
3 | Correct | 84 ms | 38952 KB | Output is correct |
4 | Correct | 37 ms | 33272 KB | Output is correct |
5 | Correct | 38 ms | 32504 KB | Output is correct |
6 | Correct | 49 ms | 34224 KB | Output is correct |
7 | Correct | 29 ms | 31736 KB | Output is correct |
8 | Correct | 63 ms | 35264 KB | Output is correct |
9 | Correct | 80 ms | 36996 KB | Output is correct |
10 | Correct | 28 ms | 31744 KB | Output is correct |
11 | Correct | 99 ms | 38364 KB | Output is correct |
12 | Correct | 112 ms | 40444 KB | Output is correct |
13 | Correct | 28 ms | 31736 KB | Output is correct |
14 | Correct | 29 ms | 31616 KB | Output is correct |
15 | Correct | 28 ms | 31744 KB | Output is correct |
16 | Correct | 28 ms | 31616 KB | Output is correct |
17 | Correct | 29 ms | 31616 KB | Output is correct |
18 | Correct | 27 ms | 31608 KB | Output is correct |
19 | Correct | 28 ms | 31608 KB | Output is correct |
20 | Correct | 28 ms | 31744 KB | Output is correct |
21 | Correct | 29 ms | 31612 KB | Output is correct |
22 | Correct | 29 ms | 31612 KB | Output is correct |
23 | Correct | 28 ms | 31616 KB | Output is correct |
24 | Correct | 29 ms | 31792 KB | Output is correct |
25 | Correct | 28 ms | 31580 KB | Output is correct |
26 | Correct | 28 ms | 31616 KB | Output is correct |
27 | Correct | 28 ms | 31708 KB | Output is correct |
28 | Incorrect | 27 ms | 31616 KB | Output isn't correct |
29 | Halted | 0 ms | 0 KB | - |