답안 #298623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
298623 2020-09-13T15:59:18 Z emil_physmath 꿈 (IOI13_dreaming) C++17
59 / 100
1000 ms 18684 KB
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
const int maxN = 100'000;
#define BUGO(x) cerr << #x << " = " << x << '\n';
struct Jmp {
    int to, w;
    operator int&() { return to; }
};

vector<Jmp> nei[maxN];
bool used[maxN];

void Maxi(auto& l, auto r) { l = max(l, r); }
int dpu[maxN], dpd[maxN];
void DFSD(int v, int par = -1)
{
    used[v] = true;
    for (Jmp& to: nei[v])
        if (to != par) {
            DFSD(to, v);
            dpd[v] = max(dpd[v], dpd[to] + to.w);
        }
}
int diam = 0, farth = maxN;
void DFSU(int v, int par = -1)
{
    if (par == -1) {
        diam = 0;
        farth = maxN;
    }
    pair<int, int> mx = {0, 0};
    for (Jmp& to: nei[v])
        if (to != par) {
            Maxi(mx.second, dpd[to] + to.w);
            if (mx.second > mx.first) swap(mx.first, mx.second);
        }
    Maxi(diam, mx.first + mx.second);
    farth = min(farth, max(dpd[v], dpu[v]));
    for (Jmp& to: nei[v])
        if (to != par)
        {
            Maxi(dpu[to], max(dpu[v], mx.first == dpd[to] + to.w ? mx.second : mx.first) + to.w);
            DFSU(to, v);
        }
}
int travelTime(int n, int m, int l, int a[], int b[], int w[]) {
    for (int i = 0; i < m; ++i) {
        nei[a[i]].push_back({b[i], w[i]});
        nei[b[i]].push_back({a[i], w[i]});
    }
    vector<int> far;
    int ans = 0;
    for (int i = 0; i < n; ++i)
        if (!used[i]) {
            DFSD(i, -1);
            DFSU(i, -1);
            far.push_back(farth);
            Maxi(ans, diam);
            BUGO(i)
            BUGO(diam)
            BUGO(farth)
        }
    sort(far.begin(), far.end(), greater<int>());
    if (far.size() >= 2)
        Maxi(ans, far[0] + l + far[1]);
    if (far.size() >= 3)
        Maxi(ans, far[1] + l + l + far[2]);
    return ans;
}

Compilation message

dreaming.cpp:14:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts'
   14 | void Maxi(auto& l, auto r) { l = max(l, r); }
      |           ^~~~
dreaming.cpp:14:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts'
   14 | void Maxi(auto& l, auto r) { l = max(l, r); }
      |                    ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 13436 KB Output is correct
2 Correct 64 ms 13176 KB Output is correct
3 Correct 49 ms 11512 KB Output is correct
4 Correct 14 ms 4224 KB Output is correct
5 Correct 8 ms 3584 KB Output is correct
6 Correct 16 ms 5120 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 29 ms 7168 KB Output is correct
9 Correct 43 ms 9592 KB Output is correct
10 Correct 3 ms 2816 KB Output is correct
11 Correct 62 ms 10620 KB Output is correct
12 Correct 80 ms 11896 KB Output is correct
13 Correct 3 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 13436 KB Output is correct
2 Correct 64 ms 13176 KB Output is correct
3 Correct 49 ms 11512 KB Output is correct
4 Correct 14 ms 4224 KB Output is correct
5 Correct 8 ms 3584 KB Output is correct
6 Correct 16 ms 5120 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 29 ms 7168 KB Output is correct
9 Correct 43 ms 9592 KB Output is correct
10 Correct 3 ms 2816 KB Output is correct
11 Correct 62 ms 10620 KB Output is correct
12 Correct 80 ms 11896 KB Output is correct
13 Correct 3 ms 2816 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 2 ms 2688 KB Output is correct
16 Correct 2 ms 2688 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 2 ms 2688 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 2 ms 2688 KB Output is correct
21 Correct 2 ms 2688 KB Output is correct
22 Correct 2 ms 2688 KB Output is correct
23 Correct 2 ms 2688 KB Output is correct
24 Correct 2 ms 2688 KB Output is correct
25 Correct 2 ms 2688 KB Output is correct
26 Correct 2 ms 2688 KB Output is correct
27 Correct 2 ms 2688 KB Output is correct
28 Correct 2 ms 2688 KB Output is correct
29 Correct 2 ms 2688 KB Output is correct
30 Correct 2 ms 2688 KB Output is correct
31 Correct 2 ms 2688 KB Output is correct
32 Correct 2 ms 2688 KB Output is correct
33 Correct 2 ms 2688 KB Output is correct
34 Correct 2 ms 2688 KB Output is correct
35 Correct 2 ms 2688 KB Output is correct
36 Correct 2 ms 2816 KB Output is correct
37 Correct 2 ms 2688 KB Output is correct
38 Correct 2 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 13436 KB Output is correct
2 Correct 64 ms 13176 KB Output is correct
3 Correct 49 ms 11512 KB Output is correct
4 Correct 14 ms 4224 KB Output is correct
5 Correct 8 ms 3584 KB Output is correct
6 Correct 16 ms 5120 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 29 ms 7168 KB Output is correct
9 Correct 43 ms 9592 KB Output is correct
10 Correct 3 ms 2816 KB Output is correct
11 Correct 62 ms 10620 KB Output is correct
12 Correct 80 ms 11896 KB Output is correct
13 Correct 3 ms 2816 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 2 ms 2688 KB Output is correct
16 Correct 2 ms 2688 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 2 ms 2688 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 2 ms 2688 KB Output is correct
21 Correct 2 ms 2688 KB Output is correct
22 Correct 2 ms 2688 KB Output is correct
23 Correct 2 ms 2688 KB Output is correct
24 Correct 2 ms 2688 KB Output is correct
25 Correct 2 ms 2688 KB Output is correct
26 Correct 2 ms 2688 KB Output is correct
27 Correct 2 ms 2688 KB Output is correct
28 Correct 2 ms 2688 KB Output is correct
29 Correct 2 ms 2688 KB Output is correct
30 Correct 2 ms 2688 KB Output is correct
31 Correct 2 ms 2688 KB Output is correct
32 Correct 2 ms 2688 KB Output is correct
33 Correct 2 ms 2688 KB Output is correct
34 Correct 2 ms 2688 KB Output is correct
35 Correct 2 ms 2688 KB Output is correct
36 Correct 2 ms 2816 KB Output is correct
37 Correct 2 ms 2688 KB Output is correct
38 Correct 2 ms 2688 KB Output is correct
39 Correct 69 ms 13560 KB Output is correct
40 Correct 66 ms 13048 KB Output is correct
41 Correct 47 ms 11640 KB Output is correct
42 Correct 10 ms 4224 KB Output is correct
43 Correct 2 ms 2688 KB Output is correct
44 Correct 2 ms 2688 KB Output is correct
45 Correct 2 ms 2688 KB Output is correct
46 Correct 2 ms 2688 KB Output is correct
47 Correct 2 ms 2688 KB Output is correct
48 Correct 2 ms 2688 KB Output is correct
49 Correct 2 ms 2688 KB Output is correct
50 Correct 2 ms 2688 KB Output is correct
51 Correct 2 ms 2688 KB Output is correct
52 Correct 2 ms 2688 KB Output is correct
53 Correct 2 ms 2688 KB Output is correct
54 Correct 2 ms 2688 KB Output is correct
55 Correct 2 ms 2688 KB Output is correct
56 Correct 2 ms 2688 KB Output is correct
57 Correct 92 ms 10104 KB Output is correct
58 Correct 95 ms 10104 KB Output is correct
59 Correct 92 ms 9976 KB Output is correct
60 Correct 93 ms 9976 KB Output is correct
61 Correct 94 ms 10104 KB Output is correct
62 Correct 92 ms 10104 KB Output is correct
63 Correct 90 ms 9848 KB Output is correct
64 Correct 86 ms 9720 KB Output is correct
65 Correct 90 ms 9976 KB Output is correct
66 Correct 95 ms 10104 KB Output is correct
67 Correct 121 ms 9976 KB Output is correct
68 Correct 92 ms 9976 KB Output is correct
69 Correct 101 ms 10360 KB Output is correct
70 Correct 104 ms 10364 KB Output is correct
71 Correct 2 ms 2688 KB Output is correct
72 Correct 4 ms 2944 KB Output is correct
73 Correct 4 ms 2944 KB Output is correct
74 Correct 4 ms 2944 KB Output is correct
75 Correct 4 ms 3072 KB Output is correct
76 Correct 4 ms 2944 KB Output is correct
77 Correct 4 ms 2944 KB Output is correct
78 Correct 5 ms 2944 KB Output is correct
79 Correct 4 ms 2944 KB Output is correct
80 Correct 98 ms 9976 KB Output is correct
81 Correct 99 ms 10052 KB Output is correct
82 Correct 98 ms 10104 KB Output is correct
83 Correct 92 ms 10080 KB Output is correct
84 Correct 3 ms 2816 KB Output is correct
85 Correct 3 ms 2816 KB Output is correct
86 Correct 3 ms 2816 KB Output is correct
87 Correct 4 ms 2816 KB Output is correct
88 Correct 4 ms 3072 KB Output is correct
89 Correct 4 ms 2816 KB Output is correct
90 Correct 4 ms 2816 KB Output is correct
91 Correct 4 ms 2944 KB Output is correct
92 Correct 4 ms 2944 KB Output is correct
93 Correct 4 ms 2944 KB Output is correct
94 Correct 2 ms 2688 KB Output is correct
95 Correct 3 ms 2816 KB Output is correct
96 Correct 2 ms 2688 KB Output is correct
97 Correct 2 ms 2688 KB Output is correct
98 Correct 2 ms 2688 KB Output is correct
99 Correct 2 ms 2688 KB Output is correct
100 Correct 2 ms 2688 KB Output is correct
101 Correct 2 ms 2688 KB Output is correct
102 Correct 2 ms 2688 KB Output is correct
103 Correct 2 ms 2688 KB Output is correct
104 Correct 9 ms 3584 KB Output is correct
105 Correct 16 ms 5120 KB Output is correct
106 Correct 2 ms 2688 KB Output is correct
107 Correct 29 ms 7168 KB Output is correct
108 Correct 41 ms 9592 KB Output is correct
109 Correct 2 ms 2816 KB Output is correct
110 Correct 63 ms 10620 KB Output is correct
111 Correct 70 ms 11896 KB Output is correct
112 Correct 3 ms 2816 KB Output is correct
113 Correct 106 ms 18684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1050 ms 7916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 13436 KB Output is correct
2 Correct 64 ms 13176 KB Output is correct
3 Correct 49 ms 11512 KB Output is correct
4 Correct 14 ms 4224 KB Output is correct
5 Correct 8 ms 3584 KB Output is correct
6 Correct 16 ms 5120 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 29 ms 7168 KB Output is correct
9 Correct 43 ms 9592 KB Output is correct
10 Correct 3 ms 2816 KB Output is correct
11 Correct 62 ms 10620 KB Output is correct
12 Correct 80 ms 11896 KB Output is correct
13 Correct 3 ms 2816 KB Output is correct
14 Correct 7 ms 2816 KB Output is correct
15 Correct 12 ms 2816 KB Output is correct
16 Correct 16 ms 2944 KB Output is correct
17 Correct 7 ms 2944 KB Output is correct
18 Correct 11 ms 2816 KB Output is correct
19 Correct 15 ms 3072 KB Output is correct
20 Correct 7 ms 2816 KB Output is correct
21 Correct 10 ms 2816 KB Output is correct
22 Correct 13 ms 2944 KB Output is correct
23 Correct 2 ms 2688 KB Output is correct
24 Correct 2 ms 2688 KB Output is correct
25 Correct 2 ms 2688 KB Output is correct
26 Correct 2 ms 2688 KB Output is correct
27 Correct 2 ms 2688 KB Output is correct
28 Correct 5 ms 2688 KB Output is correct
29 Correct 4 ms 2688 KB Output is correct
30 Correct 2 ms 2688 KB Output is correct
31 Correct 2 ms 2688 KB Output is correct
32 Correct 2 ms 2688 KB Output is correct
33 Correct 2 ms 2688 KB Output is correct
34 Correct 2 ms 2816 KB Output is correct
35 Correct 2 ms 2688 KB Output is correct
36 Correct 2 ms 2688 KB Output is correct
37 Correct 2 ms 2816 KB Output is correct
38 Correct 2 ms 2688 KB Output is correct
39 Correct 2 ms 2688 KB Output is correct
40 Correct 2 ms 2688 KB Output is correct
41 Correct 2 ms 2688 KB Output is correct
42 Correct 4 ms 3072 KB Output is correct
43 Correct 4 ms 3072 KB Output is correct
44 Correct 39 ms 2936 KB Output is correct
45 Correct 66 ms 2816 KB Output is correct
46 Correct 4 ms 3072 KB Output is correct
47 Correct 4 ms 2944 KB Output is correct
48 Correct 47 ms 2936 KB Output is correct
49 Correct 60 ms 2816 KB Output is correct
50 Correct 4 ms 2944 KB Output is correct
51 Correct 4 ms 2944 KB Output is correct
52 Correct 75 ms 2816 KB Output is correct
53 Correct 35 ms 2944 KB Output is correct
54 Correct 4 ms 2944 KB Output is correct
55 Correct 4 ms 2944 KB Output is correct
56 Correct 31 ms 2944 KB Output is correct
57 Correct 29 ms 3072 KB Output is correct
58 Correct 54 ms 2816 KB Output is correct
59 Correct 54 ms 3064 KB Output is correct
60 Correct 4 ms 2944 KB Output is correct
61 Correct 4 ms 2944 KB Output is correct
62 Correct 9 ms 2944 KB Output is correct
63 Correct 8 ms 2944 KB Output is correct
64 Correct 4 ms 2944 KB Output is correct
65 Correct 4 ms 2944 KB Output is correct
66 Correct 58 ms 2936 KB Output is correct
67 Correct 56 ms 2936 KB Output is correct
68 Correct 74 ms 2816 KB Output is correct
69 Correct 78 ms 2808 KB Output is correct
70 Correct 13 ms 2944 KB Output is correct
71 Correct 12 ms 2944 KB Output is correct
72 Correct 53 ms 2944 KB Output is correct
73 Correct 74 ms 2816 KB Output is correct
74 Correct 32 ms 2944 KB Output is correct
75 Correct 10 ms 2944 KB Output is correct
76 Correct 34 ms 2944 KB Output is correct
77 Correct 39 ms 2936 KB Output is correct
78 Correct 50 ms 2936 KB Output is correct
79 Correct 55 ms 2936 KB Output is correct
80 Correct 3 ms 2816 KB Output is correct
81 Correct 3 ms 2816 KB Output is correct
82 Correct 4 ms 2816 KB Output is correct
83 Correct 4 ms 2944 KB Output is correct
84 Correct 4 ms 2944 KB Output is correct
85 Correct 3 ms 2816 KB Output is correct
86 Correct 5 ms 2944 KB Output is correct
87 Correct 4 ms 2944 KB Output is correct
88 Correct 4 ms 2944 KB Output is correct
89 Correct 5 ms 2944 KB Output is correct
90 Correct 2 ms 2688 KB Output is correct
91 Correct 2 ms 2688 KB Output is correct
92 Correct 3 ms 2688 KB Output is correct
93 Correct 2 ms 2688 KB Output is correct
94 Correct 2 ms 2688 KB Output is correct
95 Correct 2 ms 2688 KB Output is correct
96 Correct 2 ms 2688 KB Output is correct
97 Correct 2 ms 2688 KB Output is correct
98 Correct 2 ms 2688 KB Output is correct
99 Correct 2 ms 2688 KB Output is correct
100 Correct 2 ms 2688 KB Output is correct
101 Correct 3 ms 2816 KB Output is correct
102 Correct 3 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 13436 KB Output is correct
2 Correct 64 ms 13176 KB Output is correct
3 Correct 49 ms 11512 KB Output is correct
4 Correct 14 ms 4224 KB Output is correct
5 Correct 8 ms 3584 KB Output is correct
6 Correct 16 ms 5120 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 29 ms 7168 KB Output is correct
9 Correct 43 ms 9592 KB Output is correct
10 Correct 3 ms 2816 KB Output is correct
11 Correct 62 ms 10620 KB Output is correct
12 Correct 80 ms 11896 KB Output is correct
13 Correct 3 ms 2816 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 2 ms 2688 KB Output is correct
16 Correct 2 ms 2688 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 2 ms 2688 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 2 ms 2688 KB Output is correct
21 Correct 2 ms 2688 KB Output is correct
22 Correct 2 ms 2688 KB Output is correct
23 Correct 2 ms 2688 KB Output is correct
24 Correct 2 ms 2688 KB Output is correct
25 Correct 2 ms 2688 KB Output is correct
26 Correct 2 ms 2688 KB Output is correct
27 Correct 2 ms 2688 KB Output is correct
28 Correct 2 ms 2688 KB Output is correct
29 Correct 2 ms 2688 KB Output is correct
30 Correct 2 ms 2688 KB Output is correct
31 Correct 2 ms 2688 KB Output is correct
32 Correct 2 ms 2688 KB Output is correct
33 Correct 2 ms 2688 KB Output is correct
34 Correct 2 ms 2688 KB Output is correct
35 Correct 2 ms 2688 KB Output is correct
36 Correct 2 ms 2816 KB Output is correct
37 Correct 2 ms 2688 KB Output is correct
38 Correct 2 ms 2688 KB Output is correct
39 Correct 69 ms 13560 KB Output is correct
40 Correct 66 ms 13048 KB Output is correct
41 Correct 47 ms 11640 KB Output is correct
42 Correct 10 ms 4224 KB Output is correct
43 Correct 2 ms 2688 KB Output is correct
44 Correct 2 ms 2688 KB Output is correct
45 Correct 2 ms 2688 KB Output is correct
46 Correct 2 ms 2688 KB Output is correct
47 Correct 2 ms 2688 KB Output is correct
48 Correct 2 ms 2688 KB Output is correct
49 Correct 2 ms 2688 KB Output is correct
50 Correct 2 ms 2688 KB Output is correct
51 Correct 2 ms 2688 KB Output is correct
52 Correct 2 ms 2688 KB Output is correct
53 Correct 2 ms 2688 KB Output is correct
54 Correct 2 ms 2688 KB Output is correct
55 Correct 2 ms 2688 KB Output is correct
56 Correct 2 ms 2688 KB Output is correct
57 Correct 92 ms 10104 KB Output is correct
58 Correct 95 ms 10104 KB Output is correct
59 Correct 92 ms 9976 KB Output is correct
60 Correct 93 ms 9976 KB Output is correct
61 Correct 94 ms 10104 KB Output is correct
62 Correct 92 ms 10104 KB Output is correct
63 Correct 90 ms 9848 KB Output is correct
64 Correct 86 ms 9720 KB Output is correct
65 Correct 90 ms 9976 KB Output is correct
66 Correct 95 ms 10104 KB Output is correct
67 Correct 121 ms 9976 KB Output is correct
68 Correct 92 ms 9976 KB Output is correct
69 Correct 101 ms 10360 KB Output is correct
70 Correct 104 ms 10364 KB Output is correct
71 Correct 2 ms 2688 KB Output is correct
72 Correct 4 ms 2944 KB Output is correct
73 Correct 4 ms 2944 KB Output is correct
74 Correct 4 ms 2944 KB Output is correct
75 Correct 4 ms 3072 KB Output is correct
76 Correct 4 ms 2944 KB Output is correct
77 Correct 4 ms 2944 KB Output is correct
78 Correct 5 ms 2944 KB Output is correct
79 Correct 4 ms 2944 KB Output is correct
80 Correct 98 ms 9976 KB Output is correct
81 Correct 99 ms 10052 KB Output is correct
82 Correct 98 ms 10104 KB Output is correct
83 Correct 92 ms 10080 KB Output is correct
84 Correct 3 ms 2816 KB Output is correct
85 Correct 3 ms 2816 KB Output is correct
86 Correct 3 ms 2816 KB Output is correct
87 Correct 4 ms 2816 KB Output is correct
88 Correct 4 ms 3072 KB Output is correct
89 Correct 4 ms 2816 KB Output is correct
90 Correct 4 ms 2816 KB Output is correct
91 Correct 4 ms 2944 KB Output is correct
92 Correct 4 ms 2944 KB Output is correct
93 Correct 4 ms 2944 KB Output is correct
94 Correct 2 ms 2688 KB Output is correct
95 Correct 3 ms 2816 KB Output is correct
96 Correct 2 ms 2688 KB Output is correct
97 Correct 2 ms 2688 KB Output is correct
98 Correct 2 ms 2688 KB Output is correct
99 Correct 2 ms 2688 KB Output is correct
100 Correct 2 ms 2688 KB Output is correct
101 Correct 2 ms 2688 KB Output is correct
102 Correct 2 ms 2688 KB Output is correct
103 Correct 2 ms 2688 KB Output is correct
104 Correct 9 ms 3584 KB Output is correct
105 Correct 16 ms 5120 KB Output is correct
106 Correct 2 ms 2688 KB Output is correct
107 Correct 29 ms 7168 KB Output is correct
108 Correct 41 ms 9592 KB Output is correct
109 Correct 2 ms 2816 KB Output is correct
110 Correct 63 ms 10620 KB Output is correct
111 Correct 70 ms 11896 KB Output is correct
112 Correct 3 ms 2816 KB Output is correct
113 Correct 106 ms 18684 KB Output is correct
114 Execution timed out 1050 ms 7916 KB Time limit exceeded
115 Halted 0 ms 0 KB -