답안 #728399

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
728399 2023-04-22T10:33:50 Z NeroZein 꿈 (IOI13_dreaming) C++17
47 / 100
76 ms 22704 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 mn[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]);
  };
  for (int i = 1; i <= n + 1; ++i) mn[i] = INT_MAX;
  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); 
    }
  }
  sort(mn + 1, mn + 1 + ncc); 
  int ans = max({mxd, l + mn[1] + mn[2], mn[2] + mn[3] + l + l});
  return ans; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 16076 KB Output is correct
2 Correct 48 ms 15588 KB Output is correct
3 Correct 31 ms 13716 KB Output is correct
4 Correct 8 ms 4596 KB Output is correct
5 Correct 6 ms 3796 KB Output is correct
6 Correct 11 ms 5600 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 22 ms 8176 KB Output is correct
9 Correct 32 ms 11508 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 43 ms 12236 KB Output is correct
12 Correct 47 ms 14064 KB Output is correct
13 Correct 3 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 3 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 1 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2644 KB Output is correct
14 Correct 1 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 2 ms 2644 KB Output is correct
20 Correct 1 ms 2644 KB Output is correct
21 Correct 1 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 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 16076 KB Output is correct
2 Correct 48 ms 15588 KB Output is correct
3 Correct 31 ms 13716 KB Output is correct
4 Correct 8 ms 4596 KB Output is correct
5 Correct 6 ms 3796 KB Output is correct
6 Correct 11 ms 5600 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 22 ms 8176 KB Output is correct
9 Correct 32 ms 11508 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 43 ms 12236 KB Output is correct
12 Correct 47 ms 14064 KB Output is correct
13 Correct 3 ms 2772 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 2 ms 2644 KB Output is correct
18 Correct 3 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 1 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 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 1 ms 2644 KB Output is correct
26 Correct 1 ms 2644 KB Output is correct
27 Correct 1 ms 2644 KB Output is correct
28 Correct 1 ms 2644 KB Output is correct
29 Correct 1 ms 2644 KB Output is correct
30 Correct 1 ms 2644 KB Output is correct
31 Correct 2 ms 2644 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 1 ms 2644 KB Output is correct
34 Correct 1 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 2644 KB Output is correct
39 Correct 50 ms 16128 KB Output is correct
40 Correct 43 ms 15644 KB Output is correct
41 Correct 30 ms 13672 KB Output is correct
42 Correct 7 ms 4556 KB Output is correct
43 Correct 1 ms 2644 KB Output is correct
44 Correct 1 ms 2644 KB Output is correct
45 Correct 1 ms 2644 KB Output is correct
46 Correct 2 ms 2644 KB Output is correct
47 Correct 1 ms 2644 KB Output is correct
48 Correct 2 ms 2644 KB Output is correct
49 Correct 1 ms 2644 KB Output is correct
50 Correct 1 ms 2644 KB Output is correct
51 Correct 2 ms 2644 KB Output is correct
52 Correct 2 ms 2644 KB Output is correct
53 Correct 1 ms 2644 KB Output is correct
54 Correct 1 ms 2644 KB Output is correct
55 Correct 1 ms 2644 KB Output is correct
56 Correct 2 ms 2644 KB Output is correct
57 Correct 60 ms 11212 KB Output is correct
58 Correct 59 ms 11212 KB Output is correct
59 Correct 58 ms 11232 KB Output is correct
60 Correct 63 ms 11292 KB Output is correct
61 Correct 73 ms 11116 KB Output is correct
62 Correct 61 ms 11084 KB Output is correct
63 Correct 57 ms 11016 KB Output is correct
64 Correct 59 ms 10956 KB Output is correct
65 Correct 68 ms 10956 KB Output is correct
66 Correct 62 ms 11016 KB Output is correct
67 Correct 75 ms 11336 KB Output is correct
68 Correct 68 ms 11240 KB Output is correct
69 Correct 59 ms 11308 KB Output is correct
70 Correct 66 ms 11260 KB Output is correct
71 Correct 2 ms 2644 KB Output is correct
72 Correct 3 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 65 ms 11264 KB Output is correct
81 Correct 63 ms 11288 KB Output is correct
82 Correct 55 ms 11084 KB Output is correct
83 Correct 61 ms 11116 KB Output is correct
84 Correct 3 ms 2900 KB Output is correct
85 Correct 2 ms 2772 KB Output is correct
86 Correct 2 ms 2900 KB Output is correct
87 Correct 3 ms 2900 KB Output is correct
88 Correct 3 ms 2900 KB Output is correct
89 Correct 2 ms 2900 KB Output is correct
90 Correct 3 ms 2900 KB Output is correct
91 Correct 2 ms 2900 KB Output is correct
92 Correct 2 ms 2900 KB Output is correct
93 Correct 2 ms 2900 KB Output is correct
94 Correct 1 ms 2644 KB Output is correct
95 Correct 1 ms 2644 KB Output is correct
96 Correct 2 ms 2644 KB Output is correct
97 Correct 2 ms 2644 KB Output is correct
98 Correct 2 ms 2644 KB Output is correct
99 Correct 2 ms 2644 KB Output is correct
100 Correct 1 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 2 ms 2644 KB Output is correct
104 Correct 6 ms 3796 KB Output is correct
105 Correct 11 ms 5640 KB Output is correct
106 Correct 2 ms 2644 KB Output is correct
107 Correct 21 ms 8240 KB Output is correct
108 Correct 28 ms 11416 KB Output is correct
109 Correct 2 ms 2772 KB Output is correct
110 Correct 47 ms 12216 KB Output is correct
111 Correct 52 ms 14104 KB Output is correct
112 Correct 3 ms 2772 KB Output is correct
113 Correct 76 ms 22704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 7508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 3 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 1 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2644 KB Output is correct
14 Correct 1 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 2 ms 2644 KB Output is correct
20 Correct 1 ms 2644 KB Output is correct
21 Correct 1 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 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 2 ms 2900 KB Output is correct
29 Incorrect 2 ms 2772 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 16076 KB Output is correct
2 Correct 48 ms 15588 KB Output is correct
3 Correct 31 ms 13716 KB Output is correct
4 Correct 8 ms 4596 KB Output is correct
5 Correct 6 ms 3796 KB Output is correct
6 Correct 11 ms 5600 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 22 ms 8176 KB Output is correct
9 Correct 32 ms 11508 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 43 ms 12236 KB Output is correct
12 Correct 47 ms 14064 KB Output is correct
13 Correct 3 ms 2772 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 2 ms 2644 KB Output is correct
18 Correct 3 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 1 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 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 1 ms 2644 KB Output is correct
26 Correct 1 ms 2644 KB Output is correct
27 Correct 1 ms 2644 KB Output is correct
28 Correct 1 ms 2644 KB Output is correct
29 Correct 1 ms 2644 KB Output is correct
30 Correct 1 ms 2644 KB Output is correct
31 Correct 2 ms 2644 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 1 ms 2644 KB Output is correct
34 Correct 1 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 2644 KB Output is correct
39 Correct 50 ms 16128 KB Output is correct
40 Correct 43 ms 15644 KB Output is correct
41 Correct 30 ms 13672 KB Output is correct
42 Correct 7 ms 4556 KB Output is correct
43 Correct 1 ms 2644 KB Output is correct
44 Correct 1 ms 2644 KB Output is correct
45 Correct 1 ms 2644 KB Output is correct
46 Correct 2 ms 2644 KB Output is correct
47 Correct 1 ms 2644 KB Output is correct
48 Correct 2 ms 2644 KB Output is correct
49 Correct 1 ms 2644 KB Output is correct
50 Correct 1 ms 2644 KB Output is correct
51 Correct 2 ms 2644 KB Output is correct
52 Correct 2 ms 2644 KB Output is correct
53 Correct 1 ms 2644 KB Output is correct
54 Correct 1 ms 2644 KB Output is correct
55 Correct 1 ms 2644 KB Output is correct
56 Correct 2 ms 2644 KB Output is correct
57 Correct 60 ms 11212 KB Output is correct
58 Correct 59 ms 11212 KB Output is correct
59 Correct 58 ms 11232 KB Output is correct
60 Correct 63 ms 11292 KB Output is correct
61 Correct 73 ms 11116 KB Output is correct
62 Correct 61 ms 11084 KB Output is correct
63 Correct 57 ms 11016 KB Output is correct
64 Correct 59 ms 10956 KB Output is correct
65 Correct 68 ms 10956 KB Output is correct
66 Correct 62 ms 11016 KB Output is correct
67 Correct 75 ms 11336 KB Output is correct
68 Correct 68 ms 11240 KB Output is correct
69 Correct 59 ms 11308 KB Output is correct
70 Correct 66 ms 11260 KB Output is correct
71 Correct 2 ms 2644 KB Output is correct
72 Correct 3 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 65 ms 11264 KB Output is correct
81 Correct 63 ms 11288 KB Output is correct
82 Correct 55 ms 11084 KB Output is correct
83 Correct 61 ms 11116 KB Output is correct
84 Correct 3 ms 2900 KB Output is correct
85 Correct 2 ms 2772 KB Output is correct
86 Correct 2 ms 2900 KB Output is correct
87 Correct 3 ms 2900 KB Output is correct
88 Correct 3 ms 2900 KB Output is correct
89 Correct 2 ms 2900 KB Output is correct
90 Correct 3 ms 2900 KB Output is correct
91 Correct 2 ms 2900 KB Output is correct
92 Correct 2 ms 2900 KB Output is correct
93 Correct 2 ms 2900 KB Output is correct
94 Correct 1 ms 2644 KB Output is correct
95 Correct 1 ms 2644 KB Output is correct
96 Correct 2 ms 2644 KB Output is correct
97 Correct 2 ms 2644 KB Output is correct
98 Correct 2 ms 2644 KB Output is correct
99 Correct 2 ms 2644 KB Output is correct
100 Correct 1 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 2 ms 2644 KB Output is correct
104 Correct 6 ms 3796 KB Output is correct
105 Correct 11 ms 5640 KB Output is correct
106 Correct 2 ms 2644 KB Output is correct
107 Correct 21 ms 8240 KB Output is correct
108 Correct 28 ms 11416 KB Output is correct
109 Correct 2 ms 2772 KB Output is correct
110 Correct 47 ms 12216 KB Output is correct
111 Correct 52 ms 14104 KB Output is correct
112 Correct 3 ms 2772 KB Output is correct
113 Correct 76 ms 22704 KB Output is correct
114 Incorrect 18 ms 7508 KB Output isn't correct
115 Halted 0 ms 0 KB -