답안 #728870

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
728870 2023-04-23T08:18:26 Z Rasoul006 꿈 (IOI13_dreaming) C++17
47 / 100
95 ms 18508 KB
#include "dreaming.h"

#include <bits/stdc++.h>

#define endl "\n"

#define F first

#define S second

#define pb push_back

#define all(x) x.begin() , x.end()

typedef long long ll;

using namespace std;

const int N = 1e5+5;

const long long oo = 1e18 ;

vector <pair <ll,ll>> v[N] ;

vector <ll> vec ;

ll n , m , best , mx , dis[N] , len , ans ;

bool vis[N] ;

pair <ll,ll> dfs (ll u , ll p)
{
    vis[u] = true ;

    pair <ll,ll> ret = {0 , u} ;

    for (auto it : v[u])
    {
        if (it.F == p) continue ;

        pair <ll,ll> p = dfs(it.F , u) ;

        p.F += it.S ;

        ret = max(ret , p) ;
    }

    best = min(best , max(len - ret.F , ret.F) ) ;

    return ret ;
}

ll get (ll p)
{
    ll p1 ;
    p1 = dfs(p , p).S ;
    len = dfs(p1 , p1).F ;
    ans = max(ans , len);
    best = oo ;
    dfs(p1 , p1) ;

    return best ;
}
int travelTime(int N, int M, int L, int A[], int B[], int T[])
{
    n = N ; m = M ;

    for (int i = 0 ; i<m ; i++)
    {
        v[B[i]].pb({A[i] , T[i]});
        v[A[i]].pb({B[i] , T[i]});
    }

    for (int i = 0 ; i<n ; i++)
    {
        if (!vis[i])
            vec.pb(get(i)) ;
    }

    sort (all(vec)); reverse(all(vec));

    ans = max(ans , vec[0] + vec[1] + L) ;

    if (vec.size() > 2)
        ans = max (ans , vec[1] + vec[2] + L + L) ;

    return ans ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 15308 KB Output is correct
2 Correct 45 ms 15136 KB Output is correct
3 Correct 31 ms 10864 KB Output is correct
4 Correct 7 ms 4472 KB Output is correct
5 Correct 6 ms 3668 KB Output is correct
6 Correct 11 ms 5528 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 26 ms 7116 KB Output is correct
9 Correct 33 ms 8944 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 59 ms 10828 KB Output is correct
12 Correct 60 ms 13132 KB Output is correct
13 Correct 2 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2660 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 3 ms 2664 KB Output is correct
5 Correct 2 ms 2660 KB Output is correct
6 Correct 2 ms 2660 KB Output is correct
7 Correct 2 ms 2652 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2656 KB Output is correct
10 Correct 2 ms 2660 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 2 ms 2660 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 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 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 45 ms 15308 KB Output is correct
2 Correct 45 ms 15136 KB Output is correct
3 Correct 31 ms 10864 KB Output is correct
4 Correct 7 ms 4472 KB Output is correct
5 Correct 6 ms 3668 KB Output is correct
6 Correct 11 ms 5528 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 26 ms 7116 KB Output is correct
9 Correct 33 ms 8944 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 59 ms 10828 KB Output is correct
12 Correct 60 ms 13132 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 2660 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 3 ms 2664 KB Output is correct
18 Correct 2 ms 2660 KB Output is correct
19 Correct 2 ms 2660 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2656 KB Output is correct
23 Correct 2 ms 2660 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 2 ms 2660 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 2644 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 2644 KB Output is correct
39 Correct 48 ms 16460 KB Output is correct
40 Correct 52 ms 16332 KB Output is correct
41 Correct 36 ms 11812 KB Output is correct
42 Correct 7 ms 4588 KB Output is correct
43 Correct 3 ms 2644 KB Output is correct
44 Correct 2 ms 2660 KB Output is correct
45 Correct 2 ms 2644 KB Output is correct
46 Correct 2 ms 2656 KB Output is correct
47 Correct 2 ms 2660 KB Output is correct
48 Correct 2 ms 2644 KB Output is correct
49 Correct 2 ms 2660 KB Output is correct
50 Correct 2 ms 2660 KB Output is correct
51 Correct 2 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 2 ms 2644 KB Output is correct
55 Correct 2 ms 2660 KB Output is correct
56 Correct 2 ms 2644 KB Output is correct
57 Correct 79 ms 11056 KB Output is correct
58 Correct 88 ms 11076 KB Output is correct
59 Correct 76 ms 10836 KB Output is correct
60 Correct 73 ms 10924 KB Output is correct
61 Correct 64 ms 10852 KB Output is correct
62 Correct 68 ms 10880 KB Output is correct
63 Correct 70 ms 10428 KB Output is correct
64 Correct 59 ms 10420 KB Output is correct
65 Correct 63 ms 10696 KB Output is correct
66 Correct 76 ms 10652 KB Output is correct
67 Correct 84 ms 10812 KB Output is correct
68 Correct 71 ms 10912 KB Output is correct
69 Correct 78 ms 11216 KB Output is correct
70 Correct 84 ms 11152 KB Output is correct
71 Correct 2 ms 2644 KB Output is correct
72 Correct 3 ms 2900 KB Output is correct
73 Correct 4 ms 2900 KB Output is correct
74 Correct 4 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 4 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 73 ms 10788 KB Output is correct
81 Correct 80 ms 10884 KB Output is correct
82 Correct 84 ms 10872 KB Output is correct
83 Correct 64 ms 10864 KB Output is correct
84 Correct 3 ms 2772 KB Output is correct
85 Correct 3 ms 2796 KB Output is correct
86 Correct 3 ms 2772 KB Output is correct
87 Correct 3 ms 2800 KB Output is correct
88 Correct 3 ms 2772 KB Output is correct
89 Correct 3 ms 2800 KB Output is correct
90 Correct 3 ms 2836 KB Output is correct
91 Correct 3 ms 2804 KB Output is correct
92 Correct 3 ms 2772 KB Output is correct
93 Correct 3 ms 2772 KB Output is correct
94 Correct 2 ms 2660 KB Output is correct
95 Correct 2 ms 2644 KB Output is correct
96 Correct 2 ms 2644 KB Output is correct
97 Correct 2 ms 2664 KB Output is correct
98 Correct 2 ms 2644 KB Output is correct
99 Correct 2 ms 2644 KB Output is correct
100 Correct 2 ms 2644 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 3796 KB Output is correct
105 Correct 13 ms 5844 KB Output is correct
106 Correct 2 ms 2644 KB Output is correct
107 Correct 28 ms 7644 KB Output is correct
108 Correct 39 ms 9816 KB Output is correct
109 Correct 2 ms 2664 KB Output is correct
110 Correct 48 ms 11924 KB Output is correct
111 Correct 71 ms 14368 KB Output is correct
112 Correct 2 ms 2772 KB Output is correct
113 Correct 95 ms 18508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 5720 KB Output is correct
2 Correct 21 ms 6096 KB Output is correct
3 Correct 22 ms 6096 KB Output is correct
4 Correct 22 ms 6124 KB Output is correct
5 Correct 20 ms 6128 KB Output is correct
6 Correct 20 ms 6752 KB Output is correct
7 Correct 21 ms 6232 KB Output is correct
8 Correct 24 ms 6076 KB Output is correct
9 Correct 19 ms 6056 KB Output is correct
10 Correct 22 ms 6240 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 6 ms 3928 KB Output is correct
13 Correct 6 ms 3916 KB Output is correct
14 Correct 6 ms 3916 KB Output is correct
15 Correct 6 ms 3936 KB Output is correct
16 Correct 5 ms 3916 KB Output is correct
17 Correct 5 ms 3916 KB Output is correct
18 Correct 6 ms 3896 KB Output is correct
19 Correct 6 ms 3916 KB Output is correct
20 Incorrect 2 ms 2644 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2660 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 3 ms 2664 KB Output is correct
5 Correct 2 ms 2660 KB Output is correct
6 Correct 2 ms 2660 KB Output is correct
7 Correct 2 ms 2652 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2656 KB Output is correct
10 Correct 2 ms 2660 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 2 ms 2660 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 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 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 2644 KB Output is correct
27 Correct 3 ms 2772 KB Output is correct
28 Correct 3 ms 2772 KB Output is correct
29 Correct 2 ms 2668 KB Output is correct
30 Correct 3 ms 2772 KB Output is correct
31 Correct 3 ms 2800 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 2 ms 2772 KB Output is correct
34 Correct 3 ms 2836 KB Output is correct
35 Correct 2 ms 2656 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 2 ms 2644 KB Output is correct
40 Correct 2 ms 2636 KB Output is correct
41 Correct 2 ms 2644 KB Output is correct
42 Correct 2 ms 2644 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 2664 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 2 ms 2644 KB Output is correct
51 Correct 2 ms 2644 KB Output is correct
52 Incorrect 2 ms 2644 KB Output isn't correct
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 15308 KB Output is correct
2 Correct 45 ms 15136 KB Output is correct
3 Correct 31 ms 10864 KB Output is correct
4 Correct 7 ms 4472 KB Output is correct
5 Correct 6 ms 3668 KB Output is correct
6 Correct 11 ms 5528 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 26 ms 7116 KB Output is correct
9 Correct 33 ms 8944 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 59 ms 10828 KB Output is correct
12 Correct 60 ms 13132 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 2660 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 3 ms 2664 KB Output is correct
18 Correct 2 ms 2660 KB Output is correct
19 Correct 2 ms 2660 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2656 KB Output is correct
23 Correct 2 ms 2660 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 2 ms 2660 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 2644 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 2644 KB Output is correct
39 Correct 48 ms 16460 KB Output is correct
40 Correct 52 ms 16332 KB Output is correct
41 Correct 36 ms 11812 KB Output is correct
42 Correct 7 ms 4588 KB Output is correct
43 Correct 3 ms 2644 KB Output is correct
44 Correct 2 ms 2660 KB Output is correct
45 Correct 2 ms 2644 KB Output is correct
46 Correct 2 ms 2656 KB Output is correct
47 Correct 2 ms 2660 KB Output is correct
48 Correct 2 ms 2644 KB Output is correct
49 Correct 2 ms 2660 KB Output is correct
50 Correct 2 ms 2660 KB Output is correct
51 Correct 2 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 2 ms 2644 KB Output is correct
55 Correct 2 ms 2660 KB Output is correct
56 Correct 2 ms 2644 KB Output is correct
57 Correct 79 ms 11056 KB Output is correct
58 Correct 88 ms 11076 KB Output is correct
59 Correct 76 ms 10836 KB Output is correct
60 Correct 73 ms 10924 KB Output is correct
61 Correct 64 ms 10852 KB Output is correct
62 Correct 68 ms 10880 KB Output is correct
63 Correct 70 ms 10428 KB Output is correct
64 Correct 59 ms 10420 KB Output is correct
65 Correct 63 ms 10696 KB Output is correct
66 Correct 76 ms 10652 KB Output is correct
67 Correct 84 ms 10812 KB Output is correct
68 Correct 71 ms 10912 KB Output is correct
69 Correct 78 ms 11216 KB Output is correct
70 Correct 84 ms 11152 KB Output is correct
71 Correct 2 ms 2644 KB Output is correct
72 Correct 3 ms 2900 KB Output is correct
73 Correct 4 ms 2900 KB Output is correct
74 Correct 4 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 4 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 73 ms 10788 KB Output is correct
81 Correct 80 ms 10884 KB Output is correct
82 Correct 84 ms 10872 KB Output is correct
83 Correct 64 ms 10864 KB Output is correct
84 Correct 3 ms 2772 KB Output is correct
85 Correct 3 ms 2796 KB Output is correct
86 Correct 3 ms 2772 KB Output is correct
87 Correct 3 ms 2800 KB Output is correct
88 Correct 3 ms 2772 KB Output is correct
89 Correct 3 ms 2800 KB Output is correct
90 Correct 3 ms 2836 KB Output is correct
91 Correct 3 ms 2804 KB Output is correct
92 Correct 3 ms 2772 KB Output is correct
93 Correct 3 ms 2772 KB Output is correct
94 Correct 2 ms 2660 KB Output is correct
95 Correct 2 ms 2644 KB Output is correct
96 Correct 2 ms 2644 KB Output is correct
97 Correct 2 ms 2664 KB Output is correct
98 Correct 2 ms 2644 KB Output is correct
99 Correct 2 ms 2644 KB Output is correct
100 Correct 2 ms 2644 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 3796 KB Output is correct
105 Correct 13 ms 5844 KB Output is correct
106 Correct 2 ms 2644 KB Output is correct
107 Correct 28 ms 7644 KB Output is correct
108 Correct 39 ms 9816 KB Output is correct
109 Correct 2 ms 2664 KB Output is correct
110 Correct 48 ms 11924 KB Output is correct
111 Correct 71 ms 14368 KB Output is correct
112 Correct 2 ms 2772 KB Output is correct
113 Correct 95 ms 18508 KB Output is correct
114 Correct 20 ms 5720 KB Output is correct
115 Correct 21 ms 6096 KB Output is correct
116 Correct 22 ms 6096 KB Output is correct
117 Correct 22 ms 6124 KB Output is correct
118 Correct 20 ms 6128 KB Output is correct
119 Correct 20 ms 6752 KB Output is correct
120 Correct 21 ms 6232 KB Output is correct
121 Correct 24 ms 6076 KB Output is correct
122 Correct 19 ms 6056 KB Output is correct
123 Correct 22 ms 6240 KB Output is correct
124 Correct 2 ms 2644 KB Output is correct
125 Correct 6 ms 3928 KB Output is correct
126 Correct 6 ms 3916 KB Output is correct
127 Correct 6 ms 3916 KB Output is correct
128 Correct 6 ms 3936 KB Output is correct
129 Correct 5 ms 3916 KB Output is correct
130 Correct 5 ms 3916 KB Output is correct
131 Correct 6 ms 3896 KB Output is correct
132 Correct 6 ms 3916 KB Output is correct
133 Incorrect 2 ms 2644 KB Output isn't correct
134 Halted 0 ms 0 KB -