# | Submission time^{} |
Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|

96749 | 2019-02-11T17:23:23 Z | figter001 | Dreaming (IOI13_dreaming) | C++14 | 216 ms | 12540 KB |

#include "dreaming.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5; vector<pair<int,int>> g[maxn]; vector<int> C; int mx,to,cst[maxn],t,best,mn,vis[maxn],c; void path(int u,int cost){ vis[u] = c; if(cost > mx){ mx = cost; to = u; } for(pair<int,int> cur : g[u]){ int v = cur.first; int w = cur.second; if(vis[v] == c)continue; path(v,cost + w); } } void dfs(int u,int cost){ vis[u] = c; if(t == 1){ cst[u] = max(cst[u],cost); if(cst[u] < mn){ mn = cst[u]; best = u; } }else cst[u] = cost; for(pair<int,int> cur : g[u]){ int v = cur.first; int w = cur.second; if(vis[v] == c)continue; dfs(v,cost + w); } } void find(int s){ mn = 2e9; mx = -1; c++; path(s,0); int a = to; c++; mx = -1; path(a,0); int b = to; t = 0; c++; dfs(a,0); t = 1; c++; dfs(b,0); C.push_back(best); } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { for(int i=0;i<M;i++){ g[A[i]].push_back({B[i],T[i]}); g[B[i]].push_back({A[i],T[i]}); } for(int i=0;i<N;i++) if(!vis[i]) find(i); for(int i=1;i<C.size();i++){ g[C[i]].push_back({C[0],L}); g[C[0]].push_back({C[i],L}); } c++; mx = -1; path(0,0); c++; mx = -1; path(to,0); return mx; }

### Compilation message

# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|

1 | Correct | 61 ms | 10104 KB | Output is correct |

2 | Correct | 66 ms | 10204 KB | Output is correct |

3 | Correct | 41 ms | 7544 KB | Output is correct |

4 | Correct | 11 ms | 3832 KB | Output is correct |

5 | Correct | 11 ms | 3320 KB | Output is correct |

6 | Correct | 27 ms | 4348 KB | Output is correct |

7 | Correct | 3 ms | 2680 KB | Output is correct |

8 | Correct | 36 ms | 5496 KB | Output is correct |

9 | Correct | 45 ms | 6520 KB | Output is correct |

10 | Correct | 4 ms | 2808 KB | Output is correct |

11 | Correct | 80 ms | 7804 KB | Output is correct |

12 | Correct | 93 ms | 8824 KB | Output is correct |

13 | Correct | 4 ms | 2680 KB | Output is correct |

# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|

1 | Correct | 4 ms | 2680 KB | Output is correct |

2 | Correct | 4 ms | 2680 KB | Output is correct |

3 | Correct | 4 ms | 2680 KB | Output is correct |

4 | Correct | 4 ms | 2680 KB | Output is correct |

5 | Correct | 5 ms | 2680 KB | Output is correct |

6 | Correct | 4 ms | 2680 KB | Output is correct |

7 | Correct | 4 ms | 2684 KB | Output is correct |

8 | Correct | 3 ms | 2680 KB | Output is correct |

9 | Correct | 3 ms | 2680 KB | Output is correct |

10 | Correct | 4 ms | 2684 KB | Output is correct |

11 | Correct | 4 ms | 2684 KB | Output is correct |

12 | Correct | 4 ms | 2680 KB | Output is correct |

13 | Correct | 3 ms | 2680 KB | Output is correct |

14 | Correct | 4 ms | 2680 KB | Output is correct |

15 | Correct | 3 ms | 2680 KB | Output is correct |

16 | Correct | 3 ms | 2680 KB | Output is correct |

17 | Correct | 4 ms | 2680 KB | Output is correct |

18 | Correct | 4 ms | 2680 KB | Output is correct |

19 | Correct | 4 ms | 2680 KB | Output is correct |

20 | Correct | 3 ms | 2680 KB | Output is correct |

21 | Correct | 3 ms | 2680 KB | Output is correct |

22 | Correct | 23 ms | 2680 KB | Output is correct |

23 | Correct | 4 ms | 2680 KB | Output is correct |

24 | Correct | 3 ms | 2680 KB | Output is correct |

25 | Correct | 4 ms | 2680 KB | Output is correct |

# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|

1 | Correct | 72 ms | 10212 KB | Output is correct |

2 | Correct | 67 ms | 10104 KB | Output is correct |

3 | Correct | 47 ms | 7544 KB | Output is correct |

4 | Correct | 13 ms | 3832 KB | Output is correct |

5 | Correct | 4 ms | 2680 KB | Output is correct |

6 | Correct | 4 ms | 2680 KB | Output is correct |

7 | Correct | 4 ms | 2680 KB | Output is correct |

8 | Correct | 4 ms | 2680 KB | Output is correct |

9 | Correct | 4 ms | 2680 KB | Output is correct |

10 | Correct | 4 ms | 2680 KB | Output is correct |

11 | Correct | 4 ms | 2680 KB | Output is correct |

12 | Correct | 4 ms | 2680 KB | Output is correct |

13 | Correct | 4 ms | 2680 KB | Output is correct |

14 | Correct | 4 ms | 2680 KB | Output is correct |

15 | Correct | 4 ms | 2684 KB | Output is correct |

16 | Correct | 4 ms | 2680 KB | Output is correct |

17 | Correct | 4 ms | 2680 KB | Output is correct |

18 | Correct | 4 ms | 2680 KB | Output is correct |

19 | Correct | 97 ms | 8712 KB | Output is correct |

20 | Correct | 81 ms | 8568 KB | Output is correct |

21 | Correct | 104 ms | 8556 KB | Output is correct |

22 | Correct | 146 ms | 8440 KB | Output is correct |

23 | Correct | 92 ms | 8440 KB | Output is correct |

24 | Correct | 78 ms | 8440 KB | Output is correct |

25 | Correct | 74 ms | 8312 KB | Output is correct |

26 | Correct | 76 ms | 8312 KB | Output is correct |

27 | Correct | 86 ms | 10084 KB | Output is correct |

28 | Correct | 80 ms | 9848 KB | Output is correct |

29 | Correct | 89 ms | 9892 KB | Output is correct |

30 | Correct | 119 ms | 9848 KB | Output is correct |

31 | Correct | 149 ms | 10104 KB | Output is correct |

32 | Correct | 143 ms | 10104 KB | Output is correct |

33 | Correct | 4 ms | 2680 KB | Output is correct |

34 | Correct | 6 ms | 2936 KB | Output is correct |

35 | Correct | 7 ms | 2936 KB | Output is correct |

36 | Correct | 6 ms | 2936 KB | Output is correct |

37 | Correct | 6 ms | 2936 KB | Output is correct |

38 | Correct | 6 ms | 2940 KB | Output is correct |

39 | Correct | 6 ms | 2936 KB | Output is correct |

40 | Correct | 6 ms | 2936 KB | Output is correct |

41 | Correct | 6 ms | 2808 KB | Output is correct |

42 | Correct | 150 ms | 9884 KB | Output is correct |

43 | Correct | 175 ms | 9848 KB | Output is correct |

44 | Correct | 151 ms | 9976 KB | Output is correct |

45 | Correct | 140 ms | 9976 KB | Output is correct |

46 | Correct | 6 ms | 2808 KB | Output is correct |

47 | Correct | 6 ms | 2808 KB | Output is correct |

48 | Correct | 6 ms | 2808 KB | Output is correct |

49 | Correct | 6 ms | 2936 KB | Output is correct |

50 | Correct | 6 ms | 2936 KB | Output is correct |

51 | Correct | 6 ms | 2812 KB | Output is correct |

52 | Correct | 7 ms | 2808 KB | Output is correct |

53 | Correct | 7 ms | 2936 KB | Output is correct |

54 | Correct | 6 ms | 2936 KB | Output is correct |

55 | Correct | 6 ms | 2936 KB | Output is correct |

56 | Correct | 5 ms | 2680 KB | Output is correct |

57 | Correct | 4 ms | 2680 KB | Output is correct |

58 | Correct | 4 ms | 2680 KB | Output is correct |

59 | Correct | 4 ms | 2680 KB | Output is correct |

60 | Correct | 4 ms | 2808 KB | Output is correct |

61 | Correct | 4 ms | 2680 KB | Output is correct |

62 | Correct | 4 ms | 2652 KB | Output is correct |

63 | Correct | 4 ms | 2680 KB | Output is correct |

64 | Correct | 4 ms | 2680 KB | Output is correct |

65 | Correct | 4 ms | 2680 KB | Output is correct |

66 | Correct | 12 ms | 3448 KB | Output is correct |

67 | Correct | 22 ms | 4604 KB | Output is correct |

68 | Correct | 4 ms | 2680 KB | Output is correct |

69 | Correct | 42 ms | 6008 KB | Output is correct |

70 | Correct | 52 ms | 7248 KB | Output is correct |

71 | Correct | 4 ms | 2808 KB | Output is correct |

72 | Correct | 86 ms | 8952 KB | Output is correct |

73 | Correct | 138 ms | 10060 KB | Output is correct |

74 | Correct | 5 ms | 2680 KB | Output is correct |

75 | Correct | 216 ms | 12540 KB | Output is correct |

# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|

1 | Incorrect | 54 ms | 7492 KB | Output isn't correct |

2 | Halted | 0 ms | 0 KB | - |

# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|

1 | Correct | 4 ms | 2808 KB | Output is correct |

2 | Correct | 5 ms | 2808 KB | Output is correct |

3 | Correct | 6 ms | 2936 KB | Output is correct |

4 | Incorrect | 5 ms | 2808 KB | Output isn't correct |

5 | Halted | 0 ms | 0 KB | - |

# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|

1 | Correct | 4 ms | 2680 KB | Output is correct |

2 | Correct | 5 ms | 2808 KB | Output is correct |

3 | Correct | 5 ms | 2936 KB | Output is correct |

4 | Correct | 61 ms | 7288 KB | Output is correct |

5 | Correct | 90 ms | 8696 KB | Output is correct |

6 | Incorrect | 4 ms | 2708 KB | Output isn't correct |

7 | Halted | 0 ms | 0 KB | - |