Submission #728390

# Submission time Handle Problem Language Result Execution time Memory
728390 2023-04-22T10:27:17 Z NeroZein Dreaming (IOI13_dreaming) C++17
47 / 100
82 ms 22760 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); 
  int mxd = 0;
  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]); 
    mxd = max(mxd, d[ncc]);
  };
  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(mxd, l + mxxx + mxx);
  return ans; 
}
# Verdict Execution time Memory Grader output
1 Correct 63 ms 16100 KB Output is correct
2 Correct 71 ms 15540 KB Output is correct
3 Correct 38 ms 13648 KB Output is correct
4 Correct 7 ms 4564 KB Output is correct
5 Correct 6 ms 3796 KB Output is correct
6 Correct 12 ms 5588 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 21 ms 8164 KB Output is correct
9 Correct 29 ms 11412 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 44 ms 12236 KB Output is correct
12 Correct 59 ms 14136 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 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2716 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 2644 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 1 ms 2712 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 2636 KB Output is correct
22 Correct 1 ms 2644 KB Output is correct
23 Correct 1 ms 2644 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 16100 KB Output is correct
2 Correct 71 ms 15540 KB Output is correct
3 Correct 38 ms 13648 KB Output is correct
4 Correct 7 ms 4564 KB Output is correct
5 Correct 6 ms 3796 KB Output is correct
6 Correct 12 ms 5588 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 21 ms 8164 KB Output is correct
9 Correct 29 ms 11412 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 44 ms 12236 KB Output is correct
12 Correct 59 ms 14136 KB Output is correct
13 Correct 2 ms 2772 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 1 ms 2644 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 1 ms 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 1 ms 2644 KB Output is correct
22 Correct 1 ms 2644 KB Output is correct
23 Correct 1 ms 2716 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 2644 KB Output is correct
27 Correct 2 ms 2644 KB Output is correct
28 Correct 2 ms 2644 KB Output is correct
29 Correct 2 ms 2644 KB Output is correct
30 Correct 1 ms 2712 KB Output is correct
31 Correct 1 ms 2644 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 2 ms 2644 KB Output is correct
34 Correct 2 ms 2636 KB Output is correct
35 Correct 1 ms 2644 KB Output is correct
36 Correct 1 ms 2644 KB Output is correct
37 Correct 2 ms 2644 KB Output is correct
38 Correct 2 ms 2644 KB Output is correct
39 Correct 56 ms 16124 KB Output is correct
40 Correct 47 ms 15556 KB Output is correct
41 Correct 34 ms 13780 KB Output is correct
42 Correct 7 ms 4564 KB Output is correct
43 Correct 2 ms 2644 KB Output is correct
44 Correct 2 ms 2684 KB Output is correct
45 Correct 2 ms 2644 KB Output is correct
46 Correct 2 ms 2644 KB Output is correct
47 Correct 2 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 3 ms 2608 KB Output is correct
51 Correct 3 ms 2644 KB Output is correct
52 Correct 2 ms 2644 KB Output is correct
53 Correct 2 ms 2644 KB Output is correct
54 Correct 1 ms 2644 KB Output is correct
55 Correct 2 ms 2644 KB Output is correct
56 Correct 1 ms 2644 KB Output is correct
57 Correct 58 ms 11428 KB Output is correct
58 Correct 76 ms 11228 KB Output is correct
59 Correct 82 ms 11340 KB Output is correct
60 Correct 60 ms 11216 KB Output is correct
61 Correct 58 ms 11056 KB Output is correct
62 Correct 69 ms 11164 KB Output is correct
63 Correct 60 ms 10884 KB Output is correct
64 Correct 52 ms 10892 KB Output is correct
65 Correct 81 ms 10956 KB Output is correct
66 Correct 55 ms 10956 KB Output is correct
67 Correct 55 ms 11252 KB Output is correct
68 Correct 63 ms 11344 KB Output is correct
69 Correct 63 ms 11264 KB Output is correct
70 Correct 61 ms 11340 KB Output is correct
71 Correct 2 ms 2644 KB Output is correct
72 Correct 4 ms 2900 KB Output is correct
73 Correct 3 ms 2900 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 2900 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 2900 KB Output is correct
80 Correct 75 ms 11280 KB Output is correct
81 Correct 55 ms 11196 KB Output is correct
82 Correct 76 ms 11216 KB Output is correct
83 Correct 56 ms 11084 KB Output is correct
84 Correct 3 ms 2900 KB Output is correct
85 Correct 3 ms 2772 KB Output is correct
86 Correct 3 ms 2900 KB Output is correct
87 Correct 3 ms 2900 KB Output is correct
88 Correct 2 ms 2900 KB Output is correct
89 Correct 4 ms 2900 KB Output is correct
90 Correct 2 ms 2900 KB Output is correct
91 Correct 3 ms 2900 KB Output is correct
92 Correct 3 ms 2868 KB Output is correct
93 Correct 2 ms 2900 KB Output is correct
94 Correct 1 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 1 ms 2644 KB Output is correct
100 Correct 2 ms 2644 KB Output is correct
101 Correct 1 ms 2644 KB Output is correct
102 Correct 2 ms 2644 KB Output is correct
103 Correct 1 ms 2644 KB Output is correct
104 Correct 5 ms 3836 KB Output is correct
105 Correct 11 ms 5588 KB Output is correct
106 Correct 2 ms 2644 KB Output is correct
107 Correct 22 ms 8404 KB Output is correct
108 Correct 33 ms 11456 KB Output is correct
109 Correct 2 ms 2772 KB Output is correct
110 Correct 55 ms 12240 KB Output is correct
111 Correct 64 ms 14156 KB Output is correct
112 Correct 2 ms 2772 KB Output is correct
113 Correct 71 ms 22760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 7508 KB Output is correct
2 Incorrect 19 ms 7532 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 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2716 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 2644 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 1 ms 2712 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 2636 KB Output is correct
22 Correct 1 ms 2644 KB Output is correct
23 Correct 1 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 2772 KB Output is correct
27 Correct 2 ms 2772 KB Output is correct
28 Correct 3 ms 2900 KB Output is correct
29 Correct 2 ms 2772 KB Output is correct
30 Correct 3 ms 2804 KB Output is correct
31 Correct 3 ms 2900 KB Output is correct
32 Incorrect 2 ms 2772 KB Output isn't correct
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 63 ms 16100 KB Output is correct
2 Correct 71 ms 15540 KB Output is correct
3 Correct 38 ms 13648 KB Output is correct
4 Correct 7 ms 4564 KB Output is correct
5 Correct 6 ms 3796 KB Output is correct
6 Correct 12 ms 5588 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 21 ms 8164 KB Output is correct
9 Correct 29 ms 11412 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 44 ms 12236 KB Output is correct
12 Correct 59 ms 14136 KB Output is correct
13 Correct 2 ms 2772 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 1 ms 2644 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 1 ms 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 1 ms 2644 KB Output is correct
22 Correct 1 ms 2644 KB Output is correct
23 Correct 1 ms 2716 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 2644 KB Output is correct
27 Correct 2 ms 2644 KB Output is correct
28 Correct 2 ms 2644 KB Output is correct
29 Correct 2 ms 2644 KB Output is correct
30 Correct 1 ms 2712 KB Output is correct
31 Correct 1 ms 2644 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 2 ms 2644 KB Output is correct
34 Correct 2 ms 2636 KB Output is correct
35 Correct 1 ms 2644 KB Output is correct
36 Correct 1 ms 2644 KB Output is correct
37 Correct 2 ms 2644 KB Output is correct
38 Correct 2 ms 2644 KB Output is correct
39 Correct 56 ms 16124 KB Output is correct
40 Correct 47 ms 15556 KB Output is correct
41 Correct 34 ms 13780 KB Output is correct
42 Correct 7 ms 4564 KB Output is correct
43 Correct 2 ms 2644 KB Output is correct
44 Correct 2 ms 2684 KB Output is correct
45 Correct 2 ms 2644 KB Output is correct
46 Correct 2 ms 2644 KB Output is correct
47 Correct 2 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 3 ms 2608 KB Output is correct
51 Correct 3 ms 2644 KB Output is correct
52 Correct 2 ms 2644 KB Output is correct
53 Correct 2 ms 2644 KB Output is correct
54 Correct 1 ms 2644 KB Output is correct
55 Correct 2 ms 2644 KB Output is correct
56 Correct 1 ms 2644 KB Output is correct
57 Correct 58 ms 11428 KB Output is correct
58 Correct 76 ms 11228 KB Output is correct
59 Correct 82 ms 11340 KB Output is correct
60 Correct 60 ms 11216 KB Output is correct
61 Correct 58 ms 11056 KB Output is correct
62 Correct 69 ms 11164 KB Output is correct
63 Correct 60 ms 10884 KB Output is correct
64 Correct 52 ms 10892 KB Output is correct
65 Correct 81 ms 10956 KB Output is correct
66 Correct 55 ms 10956 KB Output is correct
67 Correct 55 ms 11252 KB Output is correct
68 Correct 63 ms 11344 KB Output is correct
69 Correct 63 ms 11264 KB Output is correct
70 Correct 61 ms 11340 KB Output is correct
71 Correct 2 ms 2644 KB Output is correct
72 Correct 4 ms 2900 KB Output is correct
73 Correct 3 ms 2900 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 2900 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 2900 KB Output is correct
80 Correct 75 ms 11280 KB Output is correct
81 Correct 55 ms 11196 KB Output is correct
82 Correct 76 ms 11216 KB Output is correct
83 Correct 56 ms 11084 KB Output is correct
84 Correct 3 ms 2900 KB Output is correct
85 Correct 3 ms 2772 KB Output is correct
86 Correct 3 ms 2900 KB Output is correct
87 Correct 3 ms 2900 KB Output is correct
88 Correct 2 ms 2900 KB Output is correct
89 Correct 4 ms 2900 KB Output is correct
90 Correct 2 ms 2900 KB Output is correct
91 Correct 3 ms 2900 KB Output is correct
92 Correct 3 ms 2868 KB Output is correct
93 Correct 2 ms 2900 KB Output is correct
94 Correct 1 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 1 ms 2644 KB Output is correct
100 Correct 2 ms 2644 KB Output is correct
101 Correct 1 ms 2644 KB Output is correct
102 Correct 2 ms 2644 KB Output is correct
103 Correct 1 ms 2644 KB Output is correct
104 Correct 5 ms 3836 KB Output is correct
105 Correct 11 ms 5588 KB Output is correct
106 Correct 2 ms 2644 KB Output is correct
107 Correct 22 ms 8404 KB Output is correct
108 Correct 33 ms 11456 KB Output is correct
109 Correct 2 ms 2772 KB Output is correct
110 Correct 55 ms 12240 KB Output is correct
111 Correct 64 ms 14156 KB Output is correct
112 Correct 2 ms 2772 KB Output is correct
113 Correct 71 ms 22760 KB Output is correct
114 Correct 18 ms 7508 KB Output is correct
115 Incorrect 19 ms 7532 KB Output isn't correct
116 Halted 0 ms 0 KB -