Submission #728388

# Submission time Handle Problem Language Result Execution time Memory
728388 2023-04-22T10:25:27 Z NeroZein Dreaming (IOI13_dreaming) C++17
47 / 100
95 ms 23628 KB
#include "dreaming.h"
#include <bits/stdc++.h>
 
using namespace std; 
 
const int NN = 100005;
 
int a[NN], b[NN], t[NN];
vector<pair<int, int>> g[NN]; 
int vis[NN]; 
int mx[NN], mx2[NN]; 
int far[NN];
 
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
  int n, m, l;
  n = N, m = M, l = L; 
  for (int i = 0; i < m; ++i) {
    a[i] = A[i];
    b[i] = B[i];
    t[i] = T[i];
  }
  for (int i = 0; i < m; ++i) { 
    g[a[i]].emplace_back(b[i], t[i]);
    g[b[i]].emplace_back(a[i], t[i]); 
  }
  int ncc = 0; 
  vector<int> d(n + 1); 
  function<void(int, int)> Dfs = [&](int v, int p) {
    vis[v] = ncc; 
    for (auto [u, w] : g[v]) {
      if (u != p) {
        Dfs(u, v); 
        mx2[v] = max(mx2[v], mx[u] + w); 
        if (mx2[v] > mx[v]) {
          swap(mx2[v], mx[v]); 
        }
      }
    }
    d[ncc] = max(d[ncc], mx[v] + mx2[v]); 
  };
  vector<int> mn(n + 1, 1e9); 
  function<void(int, int, int)> Dfs2 = [&](int v, int p, int up) {
    far[v] = max(mx[v], up); 
    mn[ncc] = min(mn[ncc], far[v]); 
    for (auto [u, w] : g[v]) {
      if (u == p) continue; 
      int nup = max(up, mx[v] == mx[u] + w ? mx2[v] : mx[v]) + w; 
      Dfs2(u, v, nup); 
    }
  };
  for (int i = 0; i < n; ++i) {
    if (!vis[i]) {
      ncc++; 
      Dfs(i, i); 
      Dfs2(i, i, 0); 
    }
  }
  int mxx = 0, mxxx = 0; 
  for (int i = 1; i <= ncc; ++i) {
    mxxx = max(mxxx, mn[i]);
    if (mxxx > mxx) swap(mxxx, mxx);
  }
   int ans = max({d[1], d[2], l + mxxx + mxx});
  return ans; 
}
# Verdict Execution time Memory Grader output
1 Correct 47 ms 16716 KB Output is correct
2 Correct 47 ms 15856 KB Output is correct
3 Correct 30 ms 14036 KB Output is correct
4 Correct 7 ms 4728 KB Output is correct
5 Correct 6 ms 3924 KB Output is correct
6 Correct 12 ms 5844 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 23 ms 8776 KB Output is correct
9 Correct 28 ms 12072 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 45 ms 13232 KB Output is correct
12 Correct 53 ms 15032 KB Output is correct
13 Correct 2 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2664 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 2 ms 2660 KB Output is correct
14 Correct 2 ms 2664 KB Output is correct
15 Correct 2 ms 2664 KB Output is correct
16 Correct 1 ms 2644 KB Output is correct
17 Correct 2 ms 2628 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2664 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 16716 KB Output is correct
2 Correct 47 ms 15856 KB Output is correct
3 Correct 30 ms 14036 KB Output is correct
4 Correct 7 ms 4728 KB Output is correct
5 Correct 6 ms 3924 KB Output is correct
6 Correct 12 ms 5844 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 23 ms 8776 KB Output is correct
9 Correct 28 ms 12072 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 45 ms 13232 KB Output is correct
12 Correct 53 ms 15032 KB Output is correct
13 Correct 2 ms 2772 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 1 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2664 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
26 Correct 2 ms 2660 KB Output is correct
27 Correct 2 ms 2664 KB Output is correct
28 Correct 2 ms 2664 KB Output is correct
29 Correct 1 ms 2644 KB Output is correct
30 Correct 2 ms 2628 KB Output is correct
31 Correct 2 ms 2644 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 2 ms 2664 KB Output is correct
34 Correct 2 ms 2644 KB Output is correct
35 Correct 2 ms 2644 KB Output is correct
36 Correct 2 ms 2644 KB Output is correct
37 Correct 2 ms 2644 KB Output is correct
38 Correct 2 ms 2660 KB Output is correct
39 Correct 47 ms 16968 KB Output is correct
40 Correct 48 ms 16552 KB Output is correct
41 Correct 30 ms 14676 KB Output is correct
42 Correct 7 ms 4820 KB Output is correct
43 Correct 2 ms 2644 KB Output is correct
44 Correct 2 ms 2644 KB Output is correct
45 Correct 2 ms 2644 KB Output is correct
46 Correct 2 ms 2664 KB Output is correct
47 Correct 1 ms 2644 KB Output is correct
48 Correct 2 ms 2644 KB Output is correct
49 Correct 2 ms 2644 KB Output is correct
50 Correct 2 ms 2664 KB Output is correct
51 Correct 2 ms 2644 KB Output is correct
52 Correct 2 ms 2660 KB Output is correct
53 Correct 2 ms 2712 KB Output is correct
54 Correct 2 ms 2772 KB Output is correct
55 Correct 1 ms 2660 KB Output is correct
56 Correct 2 ms 2644 KB Output is correct
57 Correct 60 ms 12248 KB Output is correct
58 Correct 58 ms 12200 KB Output is correct
59 Correct 61 ms 12232 KB Output is correct
60 Correct 58 ms 12108 KB Output is correct
61 Correct 55 ms 12016 KB Output is correct
62 Correct 56 ms 11992 KB Output is correct
63 Correct 53 ms 11888 KB Output is correct
64 Correct 55 ms 11908 KB Output is correct
65 Correct 58 ms 11860 KB Output is correct
66 Correct 70 ms 11852 KB Output is correct
67 Correct 73 ms 12236 KB Output is correct
68 Correct 95 ms 12240 KB Output is correct
69 Correct 91 ms 12204 KB Output is correct
70 Correct 84 ms 12140 KB Output is correct
71 Correct 2 ms 2644 KB Output is correct
72 Correct 3 ms 2952 KB Output is correct
73 Correct 3 ms 2928 KB Output is correct
74 Correct 3 ms 2900 KB Output is correct
75 Correct 3 ms 2900 KB Output is correct
76 Correct 3 ms 2976 KB Output is correct
77 Correct 3 ms 2900 KB Output is correct
78 Correct 3 ms 2900 KB Output is correct
79 Correct 3 ms 2968 KB Output is correct
80 Correct 58 ms 12108 KB Output is correct
81 Correct 60 ms 12204 KB Output is correct
82 Correct 57 ms 12008 KB Output is correct
83 Correct 57 ms 11980 KB Output is correct
84 Correct 3 ms 2900 KB Output is correct
85 Correct 3 ms 2900 KB Output is correct
86 Correct 3 ms 2844 KB Output is correct
87 Correct 2 ms 2900 KB Output is correct
88 Correct 3 ms 2904 KB Output is correct
89 Correct 3 ms 2900 KB Output is correct
90 Correct 3 ms 2900 KB Output is correct
91 Correct 3 ms 2900 KB Output is correct
92 Correct 3 ms 2900 KB Output is correct
93 Correct 3 ms 2900 KB Output is correct
94 Correct 2 ms 2644 KB Output is correct
95 Correct 2 ms 2644 KB Output is correct
96 Correct 2 ms 2644 KB Output is correct
97 Correct 1 ms 2644 KB Output is correct
98 Correct 2 ms 2644 KB Output is correct
99 Correct 2 ms 2660 KB Output is correct
100 Correct 2 ms 2668 KB Output is correct
101 Correct 2 ms 2644 KB Output is correct
102 Correct 2 ms 2644 KB Output is correct
103 Correct 2 ms 2644 KB Output is correct
104 Correct 6 ms 3924 KB Output is correct
105 Correct 12 ms 5868 KB Output is correct
106 Correct 2 ms 2644 KB Output is correct
107 Correct 22 ms 8788 KB Output is correct
108 Correct 29 ms 12072 KB Output is correct
109 Correct 2 ms 2772 KB Output is correct
110 Correct 42 ms 13212 KB Output is correct
111 Correct 53 ms 15024 KB Output is correct
112 Correct 2 ms 2772 KB Output is correct
113 Correct 85 ms 23628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 7976 KB Output is correct
2 Incorrect 21 ms 8012 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2664 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 2 ms 2660 KB Output is correct
14 Correct 2 ms 2664 KB Output is correct
15 Correct 2 ms 2664 KB Output is correct
16 Correct 1 ms 2644 KB Output is correct
17 Correct 2 ms 2628 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2664 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2660 KB Output is correct
26 Incorrect 2 ms 2672 KB Output isn't correct
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 16716 KB Output is correct
2 Correct 47 ms 15856 KB Output is correct
3 Correct 30 ms 14036 KB Output is correct
4 Correct 7 ms 4728 KB Output is correct
5 Correct 6 ms 3924 KB Output is correct
6 Correct 12 ms 5844 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 23 ms 8776 KB Output is correct
9 Correct 28 ms 12072 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 45 ms 13232 KB Output is correct
12 Correct 53 ms 15032 KB Output is correct
13 Correct 2 ms 2772 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 1 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2664 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
26 Correct 2 ms 2660 KB Output is correct
27 Correct 2 ms 2664 KB Output is correct
28 Correct 2 ms 2664 KB Output is correct
29 Correct 1 ms 2644 KB Output is correct
30 Correct 2 ms 2628 KB Output is correct
31 Correct 2 ms 2644 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 2 ms 2664 KB Output is correct
34 Correct 2 ms 2644 KB Output is correct
35 Correct 2 ms 2644 KB Output is correct
36 Correct 2 ms 2644 KB Output is correct
37 Correct 2 ms 2644 KB Output is correct
38 Correct 2 ms 2660 KB Output is correct
39 Correct 47 ms 16968 KB Output is correct
40 Correct 48 ms 16552 KB Output is correct
41 Correct 30 ms 14676 KB Output is correct
42 Correct 7 ms 4820 KB Output is correct
43 Correct 2 ms 2644 KB Output is correct
44 Correct 2 ms 2644 KB Output is correct
45 Correct 2 ms 2644 KB Output is correct
46 Correct 2 ms 2664 KB Output is correct
47 Correct 1 ms 2644 KB Output is correct
48 Correct 2 ms 2644 KB Output is correct
49 Correct 2 ms 2644 KB Output is correct
50 Correct 2 ms 2664 KB Output is correct
51 Correct 2 ms 2644 KB Output is correct
52 Correct 2 ms 2660 KB Output is correct
53 Correct 2 ms 2712 KB Output is correct
54 Correct 2 ms 2772 KB Output is correct
55 Correct 1 ms 2660 KB Output is correct
56 Correct 2 ms 2644 KB Output is correct
57 Correct 60 ms 12248 KB Output is correct
58 Correct 58 ms 12200 KB Output is correct
59 Correct 61 ms 12232 KB Output is correct
60 Correct 58 ms 12108 KB Output is correct
61 Correct 55 ms 12016 KB Output is correct
62 Correct 56 ms 11992 KB Output is correct
63 Correct 53 ms 11888 KB Output is correct
64 Correct 55 ms 11908 KB Output is correct
65 Correct 58 ms 11860 KB Output is correct
66 Correct 70 ms 11852 KB Output is correct
67 Correct 73 ms 12236 KB Output is correct
68 Correct 95 ms 12240 KB Output is correct
69 Correct 91 ms 12204 KB Output is correct
70 Correct 84 ms 12140 KB Output is correct
71 Correct 2 ms 2644 KB Output is correct
72 Correct 3 ms 2952 KB Output is correct
73 Correct 3 ms 2928 KB Output is correct
74 Correct 3 ms 2900 KB Output is correct
75 Correct 3 ms 2900 KB Output is correct
76 Correct 3 ms 2976 KB Output is correct
77 Correct 3 ms 2900 KB Output is correct
78 Correct 3 ms 2900 KB Output is correct
79 Correct 3 ms 2968 KB Output is correct
80 Correct 58 ms 12108 KB Output is correct
81 Correct 60 ms 12204 KB Output is correct
82 Correct 57 ms 12008 KB Output is correct
83 Correct 57 ms 11980 KB Output is correct
84 Correct 3 ms 2900 KB Output is correct
85 Correct 3 ms 2900 KB Output is correct
86 Correct 3 ms 2844 KB Output is correct
87 Correct 2 ms 2900 KB Output is correct
88 Correct 3 ms 2904 KB Output is correct
89 Correct 3 ms 2900 KB Output is correct
90 Correct 3 ms 2900 KB Output is correct
91 Correct 3 ms 2900 KB Output is correct
92 Correct 3 ms 2900 KB Output is correct
93 Correct 3 ms 2900 KB Output is correct
94 Correct 2 ms 2644 KB Output is correct
95 Correct 2 ms 2644 KB Output is correct
96 Correct 2 ms 2644 KB Output is correct
97 Correct 1 ms 2644 KB Output is correct
98 Correct 2 ms 2644 KB Output is correct
99 Correct 2 ms 2660 KB Output is correct
100 Correct 2 ms 2668 KB Output is correct
101 Correct 2 ms 2644 KB Output is correct
102 Correct 2 ms 2644 KB Output is correct
103 Correct 2 ms 2644 KB Output is correct
104 Correct 6 ms 3924 KB Output is correct
105 Correct 12 ms 5868 KB Output is correct
106 Correct 2 ms 2644 KB Output is correct
107 Correct 22 ms 8788 KB Output is correct
108 Correct 29 ms 12072 KB Output is correct
109 Correct 2 ms 2772 KB Output is correct
110 Correct 42 ms 13212 KB Output is correct
111 Correct 53 ms 15024 KB Output is correct
112 Correct 2 ms 2772 KB Output is correct
113 Correct 85 ms 23628 KB Output is correct
114 Correct 22 ms 7976 KB Output is correct
115 Incorrect 21 ms 8012 KB Output isn't correct
116 Halted 0 ms 0 KB -