답안 #741648

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
741648 2023-05-14T13:48:52 Z vjudge1 꿈 (IOI13_dreaming) C++17
47 / 100
98 ms 17176 KB
#include "dreaming.h"
#include<bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int> > > ng;
vector<int> dis;
vector<int> par;
int dfs(int ind, int pr = -1, int cds = 0) {
    par[ind] = pr;
    if (pr == -1)dis[ind] = 0;
    else dis[ind] = cds;
    int ret = ind;
    for (int i = 0; i < ng[ind].size(); i++) {
        int neg = ng[ind][i].first;
        int ds = ng[ind][i].second;
        if (neg == par[ind])continue;
        int gt = dfs(neg, ind, ds + cds);
        if (dis[gt] > dis[ret]) ret = gt;
    }
    return ret;
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    priority_queue<pair<int, int> > pq;
    ng.resize(N);
    for (int i = 0; i < M; i++) {
        ng[A[i]].push_back(make_pair(B[i], T[i]));
        ng[B[i]].push_back(make_pair(A[i], T[i]));
    }
    dis.resize(N, 0);
    par.resize(N, -2);
    int rez = 0;
    vector<int> vals;
    for (int i = 0; i < N; i++) {
        if (par[i] != -2) continue;
        int far = dfs(i);
        int it = far = dfs(far);
        int ind = it, v2 = dis[far];
        while (par[it] != -1) {
            int v1 = max(dis[far] - dis[it], dis[it]);
            if (v1 < v2) {
                v2 = v1;
                ind = it;
            }
            it = par[it];
        }
        rez = max(rez, dis[far]);
        vals.push_back(v2);
    }
    sort(vals.begin(), vals.end());
    reverse(vals.begin(), vals.end());
    rez = max(rez, vals[0] + vals[1] + L);
    if (vals.size() > 2) rez = max(rez, vals[1] + vals[2] + L + L);
    return rez;
}

Compilation message

dreaming.cpp: In function 'int dfs(int, int, int)':
dreaming.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int i = 0; i < ng[ind].size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~~
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:36:13: warning: variable 'ind' set but not used [-Wunused-but-set-variable]
   36 |         int ind = it, v2 = dis[far];
      |             ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 14156 KB Output is correct
2 Correct 66 ms 14092 KB Output is correct
3 Correct 28 ms 9368 KB Output is correct
4 Correct 7 ms 2260 KB Output is correct
5 Correct 5 ms 1456 KB Output is correct
6 Correct 11 ms 3348 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 22 ms 5076 KB Output is correct
9 Correct 28 ms 7100 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 45 ms 9164 KB Output is correct
12 Correct 63 ms 11648 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 14156 KB Output is correct
2 Correct 66 ms 14092 KB Output is correct
3 Correct 28 ms 9368 KB Output is correct
4 Correct 7 ms 2260 KB Output is correct
5 Correct 5 ms 1456 KB Output is correct
6 Correct 11 ms 3348 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 22 ms 5076 KB Output is correct
9 Correct 28 ms 7100 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 45 ms 9164 KB Output is correct
12 Correct 63 ms 11648 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 320 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 45 ms 15424 KB Output is correct
40 Correct 45 ms 15324 KB Output is correct
41 Correct 27 ms 10324 KB Output is correct
42 Correct 6 ms 2516 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 0 ms 212 KB Output is correct
55 Correct 0 ms 308 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 65 ms 9936 KB Output is correct
58 Correct 68 ms 9944 KB Output is correct
59 Correct 59 ms 9892 KB Output is correct
60 Correct 52 ms 9916 KB Output is correct
61 Correct 49 ms 9964 KB Output is correct
62 Correct 54 ms 9932 KB Output is correct
63 Correct 65 ms 9628 KB Output is correct
64 Correct 77 ms 9592 KB Output is correct
65 Correct 53 ms 9912 KB Output is correct
66 Correct 58 ms 9804 KB Output is correct
67 Correct 62 ms 9884 KB Output is correct
68 Correct 69 ms 9804 KB Output is correct
69 Correct 79 ms 10160 KB Output is correct
70 Correct 61 ms 10060 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 2 ms 596 KB Output is correct
73 Correct 2 ms 596 KB Output is correct
74 Correct 2 ms 484 KB Output is correct
75 Correct 2 ms 596 KB Output is correct
76 Correct 2 ms 596 KB Output is correct
77 Correct 2 ms 596 KB Output is correct
78 Correct 2 ms 596 KB Output is correct
79 Correct 2 ms 596 KB Output is correct
80 Correct 51 ms 9824 KB Output is correct
81 Correct 51 ms 9804 KB Output is correct
82 Correct 50 ms 9912 KB Output is correct
83 Correct 52 ms 9932 KB Output is correct
84 Correct 1 ms 468 KB Output is correct
85 Correct 1 ms 468 KB Output is correct
86 Correct 1 ms 468 KB Output is correct
87 Correct 2 ms 468 KB Output is correct
88 Correct 2 ms 468 KB Output is correct
89 Correct 2 ms 468 KB Output is correct
90 Correct 2 ms 448 KB Output is correct
91 Correct 2 ms 572 KB Output is correct
92 Correct 2 ms 468 KB Output is correct
93 Correct 2 ms 468 KB Output is correct
94 Correct 0 ms 212 KB Output is correct
95 Correct 1 ms 212 KB Output is correct
96 Correct 0 ms 212 KB Output is correct
97 Correct 1 ms 212 KB Output is correct
98 Correct 1 ms 312 KB Output is correct
99 Correct 1 ms 212 KB Output is correct
100 Correct 1 ms 212 KB Output is correct
101 Correct 1 ms 312 KB Output is correct
102 Correct 1 ms 212 KB Output is correct
103 Correct 0 ms 212 KB Output is correct
104 Correct 4 ms 1492 KB Output is correct
105 Correct 10 ms 3656 KB Output is correct
106 Correct 1 ms 300 KB Output is correct
107 Correct 19 ms 5660 KB Output is correct
108 Correct 25 ms 7824 KB Output is correct
109 Correct 1 ms 340 KB Output is correct
110 Correct 37 ms 10312 KB Output is correct
111 Correct 49 ms 12876 KB Output is correct
112 Correct 1 ms 340 KB Output is correct
113 Correct 98 ms 17176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 5844 KB Output is correct
2 Correct 16 ms 5972 KB Output is correct
3 Correct 18 ms 5860 KB Output is correct
4 Correct 17 ms 5972 KB Output is correct
5 Correct 17 ms 5904 KB Output is correct
6 Correct 18 ms 6476 KB Output is correct
7 Correct 18 ms 6200 KB Output is correct
8 Correct 19 ms 5876 KB Output is correct
9 Correct 16 ms 5788 KB Output is correct
10 Correct 19 ms 6080 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 6 ms 4048 KB Output is correct
13 Correct 5 ms 4048 KB Output is correct
14 Correct 5 ms 4048 KB Output is correct
15 Correct 5 ms 4048 KB Output is correct
16 Correct 6 ms 4048 KB Output is correct
17 Correct 6 ms 4048 KB Output is correct
18 Correct 5 ms 4048 KB Output is correct
19 Correct 5 ms 4048 KB Output is correct
20 Incorrect 0 ms 212 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 2 ms 480 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 2 ms 468 KB Output is correct
35 Correct 1 ms 308 KB Output is correct
36 Correct 1 ms 312 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 308 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 304 KB Output is correct
43 Correct 1 ms 312 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Incorrect 1 ms 212 KB Output isn't correct
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 14156 KB Output is correct
2 Correct 66 ms 14092 KB Output is correct
3 Correct 28 ms 9368 KB Output is correct
4 Correct 7 ms 2260 KB Output is correct
5 Correct 5 ms 1456 KB Output is correct
6 Correct 11 ms 3348 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 22 ms 5076 KB Output is correct
9 Correct 28 ms 7100 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 45 ms 9164 KB Output is correct
12 Correct 63 ms 11648 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 320 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 45 ms 15424 KB Output is correct
40 Correct 45 ms 15324 KB Output is correct
41 Correct 27 ms 10324 KB Output is correct
42 Correct 6 ms 2516 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 0 ms 212 KB Output is correct
55 Correct 0 ms 308 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 65 ms 9936 KB Output is correct
58 Correct 68 ms 9944 KB Output is correct
59 Correct 59 ms 9892 KB Output is correct
60 Correct 52 ms 9916 KB Output is correct
61 Correct 49 ms 9964 KB Output is correct
62 Correct 54 ms 9932 KB Output is correct
63 Correct 65 ms 9628 KB Output is correct
64 Correct 77 ms 9592 KB Output is correct
65 Correct 53 ms 9912 KB Output is correct
66 Correct 58 ms 9804 KB Output is correct
67 Correct 62 ms 9884 KB Output is correct
68 Correct 69 ms 9804 KB Output is correct
69 Correct 79 ms 10160 KB Output is correct
70 Correct 61 ms 10060 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 2 ms 596 KB Output is correct
73 Correct 2 ms 596 KB Output is correct
74 Correct 2 ms 484 KB Output is correct
75 Correct 2 ms 596 KB Output is correct
76 Correct 2 ms 596 KB Output is correct
77 Correct 2 ms 596 KB Output is correct
78 Correct 2 ms 596 KB Output is correct
79 Correct 2 ms 596 KB Output is correct
80 Correct 51 ms 9824 KB Output is correct
81 Correct 51 ms 9804 KB Output is correct
82 Correct 50 ms 9912 KB Output is correct
83 Correct 52 ms 9932 KB Output is correct
84 Correct 1 ms 468 KB Output is correct
85 Correct 1 ms 468 KB Output is correct
86 Correct 1 ms 468 KB Output is correct
87 Correct 2 ms 468 KB Output is correct
88 Correct 2 ms 468 KB Output is correct
89 Correct 2 ms 468 KB Output is correct
90 Correct 2 ms 448 KB Output is correct
91 Correct 2 ms 572 KB Output is correct
92 Correct 2 ms 468 KB Output is correct
93 Correct 2 ms 468 KB Output is correct
94 Correct 0 ms 212 KB Output is correct
95 Correct 1 ms 212 KB Output is correct
96 Correct 0 ms 212 KB Output is correct
97 Correct 1 ms 212 KB Output is correct
98 Correct 1 ms 312 KB Output is correct
99 Correct 1 ms 212 KB Output is correct
100 Correct 1 ms 212 KB Output is correct
101 Correct 1 ms 312 KB Output is correct
102 Correct 1 ms 212 KB Output is correct
103 Correct 0 ms 212 KB Output is correct
104 Correct 4 ms 1492 KB Output is correct
105 Correct 10 ms 3656 KB Output is correct
106 Correct 1 ms 300 KB Output is correct
107 Correct 19 ms 5660 KB Output is correct
108 Correct 25 ms 7824 KB Output is correct
109 Correct 1 ms 340 KB Output is correct
110 Correct 37 ms 10312 KB Output is correct
111 Correct 49 ms 12876 KB Output is correct
112 Correct 1 ms 340 KB Output is correct
113 Correct 98 ms 17176 KB Output is correct
114 Correct 25 ms 5844 KB Output is correct
115 Correct 16 ms 5972 KB Output is correct
116 Correct 18 ms 5860 KB Output is correct
117 Correct 17 ms 5972 KB Output is correct
118 Correct 17 ms 5904 KB Output is correct
119 Correct 18 ms 6476 KB Output is correct
120 Correct 18 ms 6200 KB Output is correct
121 Correct 19 ms 5876 KB Output is correct
122 Correct 16 ms 5788 KB Output is correct
123 Correct 19 ms 6080 KB Output is correct
124 Correct 0 ms 212 KB Output is correct
125 Correct 6 ms 4048 KB Output is correct
126 Correct 5 ms 4048 KB Output is correct
127 Correct 5 ms 4048 KB Output is correct
128 Correct 5 ms 4048 KB Output is correct
129 Correct 6 ms 4048 KB Output is correct
130 Correct 6 ms 4048 KB Output is correct
131 Correct 5 ms 4048 KB Output is correct
132 Correct 5 ms 4048 KB Output is correct
133 Incorrect 0 ms 212 KB Output isn't correct
134 Halted 0 ms 0 KB -