답안 #727082

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
727082 2023-04-20T03:30:17 Z hoainiem 꿈 (IOI13_dreaming) C++14
47 / 100
82 ms 10224 KB
#include "dreaming.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define nmax 100008
const int inf = 1e9 + 7;
using namespace std;
typedef pair<int, int> pii;
vector<pii>vt, l[nmax];
bool kt[nmax], vis[nmax];
int n, dis[2][nmax];
stack<int>s;
void bfs(int root, int id){
    fill(dis[id], dis[id] + nmax, -1);
    s.push(root);
    dis[id][root] = 0;
    while (!s.empty()){
        int u = s.top();
        s.pop();
        kt[u] = vis[u] = true;
        for (pii it : l[u])
            if (dis[id][it.fi] == -1){
                dis[id][it.fi] = dis[id][u] + it.se;
                s.push(it.fi);
            }
    }
}
pii calc(int rt){
    fill(kt, kt + n + 1, false);
    bfs(rt, 0);
    int u = 0, v = 0, res = inf;
    for (int i = 1; i < n; i++)
        if (dis[0][u] < dis[0][i])
            u = i;
    bfs(u, 1);
    for (int i = 1; i < n; i++)
        if (dis[1][v] < dis[1][i])
            v = i;
    bfs(v, 0);
    for (int i = 0; i < n; i++)
        if (kt[i])
            res = min(res, max(dis[0][i], dis[1][i]));
    return {dis[0][u], res};
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    n = N;
    for (int i = 0; i < M; i++){
        int u = A[i], v = B[i], w = T[i];
        l[u].push_back({v, w});
        l[v].push_back({u, w});
    }
    assert(M == N - 2);
    fill(vis, vis + n + 1, false);
    for (int i = 0; i < N; i++)
        if (!vis[i])
            vt.push_back(calc(i));
    return max({vt[0].fi, vt[1].fi, vt[0].se + vt[1].se + L});
}
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 7788 KB Output is correct
2 Correct 43 ms 8752 KB Output is correct
3 Correct 39 ms 6976 KB Output is correct
4 Correct 7 ms 4180 KB Output is correct
5 Correct 7 ms 3924 KB Output is correct
6 Correct 12 ms 4596 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 24 ms 5708 KB Output is correct
9 Correct 28 ms 6380 KB Output is correct
10 Correct 2 ms 3412 KB Output is correct
11 Correct 43 ms 7664 KB Output is correct
12 Correct 46 ms 8140 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3428 KB Output is correct
2 Correct 2 ms 3428 KB Output is correct
3 Correct 2 ms 3436 KB Output is correct
4 Correct 2 ms 3428 KB Output is correct
5 Correct 2 ms 3412 KB Output is correct
6 Correct 3 ms 3456 KB Output is correct
7 Correct 3 ms 3412 KB Output is correct
8 Correct 3 ms 3412 KB Output is correct
9 Correct 3 ms 3376 KB Output is correct
10 Correct 2 ms 3412 KB Output is correct
11 Correct 2 ms 3412 KB Output is correct
12 Correct 2 ms 3412 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
14 Correct 2 ms 3428 KB Output is correct
15 Correct 3 ms 3432 KB Output is correct
16 Correct 2 ms 3428 KB Output is correct
17 Correct 3 ms 3412 KB Output is correct
18 Correct 3 ms 3412 KB Output is correct
19 Correct 2 ms 3412 KB Output is correct
20 Correct 2 ms 3428 KB Output is correct
21 Correct 2 ms 3412 KB Output is correct
22 Correct 3 ms 3432 KB Output is correct
23 Correct 3 ms 3412 KB Output is correct
24 Correct 2 ms 3412 KB Output is correct
25 Correct 2 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 7788 KB Output is correct
2 Correct 43 ms 8752 KB Output is correct
3 Correct 39 ms 6976 KB Output is correct
4 Correct 7 ms 4180 KB Output is correct
5 Correct 7 ms 3924 KB Output is correct
6 Correct 12 ms 4596 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 24 ms 5708 KB Output is correct
9 Correct 28 ms 6380 KB Output is correct
10 Correct 2 ms 3412 KB Output is correct
11 Correct 43 ms 7664 KB Output is correct
12 Correct 46 ms 8140 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
14 Correct 2 ms 3428 KB Output is correct
15 Correct 2 ms 3428 KB Output is correct
16 Correct 2 ms 3436 KB Output is correct
17 Correct 2 ms 3428 KB Output is correct
18 Correct 2 ms 3412 KB Output is correct
19 Correct 3 ms 3456 KB Output is correct
20 Correct 3 ms 3412 KB Output is correct
21 Correct 3 ms 3412 KB Output is correct
22 Correct 3 ms 3376 KB Output is correct
23 Correct 2 ms 3412 KB Output is correct
24 Correct 2 ms 3412 KB Output is correct
25 Correct 2 ms 3412 KB Output is correct
26 Correct 2 ms 3412 KB Output is correct
27 Correct 2 ms 3428 KB Output is correct
28 Correct 3 ms 3432 KB Output is correct
29 Correct 2 ms 3428 KB Output is correct
30 Correct 3 ms 3412 KB Output is correct
31 Correct 3 ms 3412 KB Output is correct
32 Correct 2 ms 3412 KB Output is correct
33 Correct 2 ms 3428 KB Output is correct
34 Correct 2 ms 3412 KB Output is correct
35 Correct 3 ms 3432 KB Output is correct
36 Correct 3 ms 3412 KB Output is correct
37 Correct 2 ms 3412 KB Output is correct
38 Correct 2 ms 3412 KB Output is correct
39 Correct 40 ms 8672 KB Output is correct
40 Correct 43 ms 8756 KB Output is correct
41 Correct 37 ms 7120 KB Output is correct
42 Correct 7 ms 4180 KB Output is correct
43 Correct 3 ms 3412 KB Output is correct
44 Correct 2 ms 3412 KB Output is correct
45 Correct 2 ms 3412 KB Output is correct
46 Correct 2 ms 3424 KB Output is correct
47 Correct 2 ms 3412 KB Output is correct
48 Correct 2 ms 3432 KB Output is correct
49 Correct 2 ms 3428 KB Output is correct
50 Correct 2 ms 3428 KB Output is correct
51 Correct 2 ms 3428 KB Output is correct
52 Correct 2 ms 3412 KB Output is correct
53 Correct 3 ms 3416 KB Output is correct
54 Correct 3 ms 3412 KB Output is correct
55 Correct 2 ms 3428 KB Output is correct
56 Correct 2 ms 3412 KB Output is correct
57 Correct 60 ms 10120 KB Output is correct
58 Correct 60 ms 10104 KB Output is correct
59 Correct 63 ms 9980 KB Output is correct
60 Correct 63 ms 9868 KB Output is correct
61 Correct 67 ms 10144 KB Output is correct
62 Correct 62 ms 10140 KB Output is correct
63 Correct 63 ms 9756 KB Output is correct
64 Correct 64 ms 9716 KB Output is correct
65 Correct 69 ms 10088 KB Output is correct
66 Correct 70 ms 10048 KB Output is correct
67 Correct 60 ms 9932 KB Output is correct
68 Correct 61 ms 10040 KB Output is correct
69 Correct 61 ms 10168 KB Output is correct
70 Correct 64 ms 10176 KB Output is correct
71 Correct 2 ms 3412 KB Output is correct
72 Correct 3 ms 3540 KB Output is correct
73 Correct 3 ms 3572 KB Output is correct
74 Correct 3 ms 3540 KB Output is correct
75 Correct 3 ms 3568 KB Output is correct
76 Correct 3 ms 3580 KB Output is correct
77 Correct 4 ms 3572 KB Output is correct
78 Correct 3 ms 3576 KB Output is correct
79 Correct 3 ms 3576 KB Output is correct
80 Correct 67 ms 9932 KB Output is correct
81 Correct 82 ms 9932 KB Output is correct
82 Correct 63 ms 10060 KB Output is correct
83 Correct 56 ms 10196 KB Output is correct
84 Correct 3 ms 3540 KB Output is correct
85 Correct 3 ms 3568 KB Output is correct
86 Correct 3 ms 3700 KB Output is correct
87 Correct 4 ms 3540 KB Output is correct
88 Correct 3 ms 3608 KB Output is correct
89 Correct 4 ms 3568 KB Output is correct
90 Correct 3 ms 3540 KB Output is correct
91 Correct 3 ms 3540 KB Output is correct
92 Correct 3 ms 3568 KB Output is correct
93 Correct 3 ms 3540 KB Output is correct
94 Correct 2 ms 3412 KB Output is correct
95 Correct 2 ms 3412 KB Output is correct
96 Correct 2 ms 3412 KB Output is correct
97 Correct 2 ms 3412 KB Output is correct
98 Correct 2 ms 3412 KB Output is correct
99 Correct 2 ms 3428 KB Output is correct
100 Correct 2 ms 3412 KB Output is correct
101 Correct 2 ms 3352 KB Output is correct
102 Correct 2 ms 3412 KB Output is correct
103 Correct 2 ms 3412 KB Output is correct
104 Correct 8 ms 3924 KB Output is correct
105 Correct 16 ms 4596 KB Output is correct
106 Correct 2 ms 3436 KB Output is correct
107 Correct 21 ms 5692 KB Output is correct
108 Correct 25 ms 6320 KB Output is correct
109 Correct 2 ms 3412 KB Output is correct
110 Correct 42 ms 7788 KB Output is correct
111 Correct 42 ms 8020 KB Output is correct
112 Correct 2 ms 3412 KB Output is correct
113 Correct 75 ms 9544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 10224 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3428 KB Output is correct
2 Correct 2 ms 3428 KB Output is correct
3 Correct 2 ms 3436 KB Output is correct
4 Correct 2 ms 3428 KB Output is correct
5 Correct 2 ms 3412 KB Output is correct
6 Correct 3 ms 3456 KB Output is correct
7 Correct 3 ms 3412 KB Output is correct
8 Correct 3 ms 3412 KB Output is correct
9 Correct 3 ms 3376 KB Output is correct
10 Correct 2 ms 3412 KB Output is correct
11 Correct 2 ms 3412 KB Output is correct
12 Correct 2 ms 3412 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
14 Correct 2 ms 3428 KB Output is correct
15 Correct 3 ms 3432 KB Output is correct
16 Correct 2 ms 3428 KB Output is correct
17 Correct 3 ms 3412 KB Output is correct
18 Correct 3 ms 3412 KB Output is correct
19 Correct 2 ms 3412 KB Output is correct
20 Correct 2 ms 3428 KB Output is correct
21 Correct 2 ms 3412 KB Output is correct
22 Correct 3 ms 3432 KB Output is correct
23 Correct 3 ms 3412 KB Output is correct
24 Correct 2 ms 3412 KB Output is correct
25 Correct 2 ms 3412 KB Output is correct
26 Runtime error 4 ms 5332 KB Execution killed with signal 6
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 7788 KB Output is correct
2 Correct 43 ms 8752 KB Output is correct
3 Correct 39 ms 6976 KB Output is correct
4 Correct 7 ms 4180 KB Output is correct
5 Correct 7 ms 3924 KB Output is correct
6 Correct 12 ms 4596 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 24 ms 5708 KB Output is correct
9 Correct 28 ms 6380 KB Output is correct
10 Correct 2 ms 3412 KB Output is correct
11 Correct 43 ms 7664 KB Output is correct
12 Correct 46 ms 8140 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
14 Correct 2 ms 3428 KB Output is correct
15 Correct 2 ms 3428 KB Output is correct
16 Correct 2 ms 3436 KB Output is correct
17 Correct 2 ms 3428 KB Output is correct
18 Correct 2 ms 3412 KB Output is correct
19 Correct 3 ms 3456 KB Output is correct
20 Correct 3 ms 3412 KB Output is correct
21 Correct 3 ms 3412 KB Output is correct
22 Correct 3 ms 3376 KB Output is correct
23 Correct 2 ms 3412 KB Output is correct
24 Correct 2 ms 3412 KB Output is correct
25 Correct 2 ms 3412 KB Output is correct
26 Correct 2 ms 3412 KB Output is correct
27 Correct 2 ms 3428 KB Output is correct
28 Correct 3 ms 3432 KB Output is correct
29 Correct 2 ms 3428 KB Output is correct
30 Correct 3 ms 3412 KB Output is correct
31 Correct 3 ms 3412 KB Output is correct
32 Correct 2 ms 3412 KB Output is correct
33 Correct 2 ms 3428 KB Output is correct
34 Correct 2 ms 3412 KB Output is correct
35 Correct 3 ms 3432 KB Output is correct
36 Correct 3 ms 3412 KB Output is correct
37 Correct 2 ms 3412 KB Output is correct
38 Correct 2 ms 3412 KB Output is correct
39 Correct 40 ms 8672 KB Output is correct
40 Correct 43 ms 8756 KB Output is correct
41 Correct 37 ms 7120 KB Output is correct
42 Correct 7 ms 4180 KB Output is correct
43 Correct 3 ms 3412 KB Output is correct
44 Correct 2 ms 3412 KB Output is correct
45 Correct 2 ms 3412 KB Output is correct
46 Correct 2 ms 3424 KB Output is correct
47 Correct 2 ms 3412 KB Output is correct
48 Correct 2 ms 3432 KB Output is correct
49 Correct 2 ms 3428 KB Output is correct
50 Correct 2 ms 3428 KB Output is correct
51 Correct 2 ms 3428 KB Output is correct
52 Correct 2 ms 3412 KB Output is correct
53 Correct 3 ms 3416 KB Output is correct
54 Correct 3 ms 3412 KB Output is correct
55 Correct 2 ms 3428 KB Output is correct
56 Correct 2 ms 3412 KB Output is correct
57 Correct 60 ms 10120 KB Output is correct
58 Correct 60 ms 10104 KB Output is correct
59 Correct 63 ms 9980 KB Output is correct
60 Correct 63 ms 9868 KB Output is correct
61 Correct 67 ms 10144 KB Output is correct
62 Correct 62 ms 10140 KB Output is correct
63 Correct 63 ms 9756 KB Output is correct
64 Correct 64 ms 9716 KB Output is correct
65 Correct 69 ms 10088 KB Output is correct
66 Correct 70 ms 10048 KB Output is correct
67 Correct 60 ms 9932 KB Output is correct
68 Correct 61 ms 10040 KB Output is correct
69 Correct 61 ms 10168 KB Output is correct
70 Correct 64 ms 10176 KB Output is correct
71 Correct 2 ms 3412 KB Output is correct
72 Correct 3 ms 3540 KB Output is correct
73 Correct 3 ms 3572 KB Output is correct
74 Correct 3 ms 3540 KB Output is correct
75 Correct 3 ms 3568 KB Output is correct
76 Correct 3 ms 3580 KB Output is correct
77 Correct 4 ms 3572 KB Output is correct
78 Correct 3 ms 3576 KB Output is correct
79 Correct 3 ms 3576 KB Output is correct
80 Correct 67 ms 9932 KB Output is correct
81 Correct 82 ms 9932 KB Output is correct
82 Correct 63 ms 10060 KB Output is correct
83 Correct 56 ms 10196 KB Output is correct
84 Correct 3 ms 3540 KB Output is correct
85 Correct 3 ms 3568 KB Output is correct
86 Correct 3 ms 3700 KB Output is correct
87 Correct 4 ms 3540 KB Output is correct
88 Correct 3 ms 3608 KB Output is correct
89 Correct 4 ms 3568 KB Output is correct
90 Correct 3 ms 3540 KB Output is correct
91 Correct 3 ms 3540 KB Output is correct
92 Correct 3 ms 3568 KB Output is correct
93 Correct 3 ms 3540 KB Output is correct
94 Correct 2 ms 3412 KB Output is correct
95 Correct 2 ms 3412 KB Output is correct
96 Correct 2 ms 3412 KB Output is correct
97 Correct 2 ms 3412 KB Output is correct
98 Correct 2 ms 3412 KB Output is correct
99 Correct 2 ms 3428 KB Output is correct
100 Correct 2 ms 3412 KB Output is correct
101 Correct 2 ms 3352 KB Output is correct
102 Correct 2 ms 3412 KB Output is correct
103 Correct 2 ms 3412 KB Output is correct
104 Correct 8 ms 3924 KB Output is correct
105 Correct 16 ms 4596 KB Output is correct
106 Correct 2 ms 3436 KB Output is correct
107 Correct 21 ms 5692 KB Output is correct
108 Correct 25 ms 6320 KB Output is correct
109 Correct 2 ms 3412 KB Output is correct
110 Correct 42 ms 7788 KB Output is correct
111 Correct 42 ms 8020 KB Output is correct
112 Correct 2 ms 3412 KB Output is correct
113 Correct 75 ms 9544 KB Output is correct
114 Runtime error 16 ms 10224 KB Execution killed with signal 6
115 Halted 0 ms 0 KB -