답안 #727104

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
727104 2023-04-20T04:04:48 Z hoainiem 꿈 (IOI13_dreaming) C++14
59 / 100
1000 ms 9176 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;
pii operator+(pii x, int y){
    return (x.fi <= y) ? make_pair(y, x.fi) : ((x.se < y) ? make_pair(x.fi, y) : x);
}
pii operator+(pii x, pii y){
    return (x + y.fi) + y.se;
}
vector<pii>vt, l[nmax];
bool kt[nmax], vis[nmax];
int n, d = 0, ans = inf, diameter = 0, dis[2][nmax];
stack<int>s;
int a[nmax];
pii pf[nmax], sf[nmax];
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);
            }
    }
}
int 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]));
    diameter = max(diameter, dis[0][u]);
    return 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);
    pf[0] = {-inf, -inf};
    for (int i = 0; i < N; i++)
        if (!vis[i]){
            a[++d] = calc(i);
            pf[d] = pf[d - 1] + a[d];
        }
    sf[d + 1] = {-inf, -inf};
    for (int i = d; i > 0; i--)
        sf[i] = sf[i + 1] + a[i];
    if (M == N - 2)
        return max(diameter, a[2] + a[1] + L);
    for (int i = 1; i <= d; i++){
        pii cur = pf[i - 1] + sf[i + 1];
        ans = min(ans, max({diameter, cur.fi + cur.se + L * 2, cur.fi + a[i] + L}));
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 7500 KB Output is correct
2 Correct 39 ms 7524 KB Output is correct
3 Correct 25 ms 6148 KB Output is correct
4 Correct 7 ms 4084 KB Output is correct
5 Correct 6 ms 3920 KB Output is correct
6 Correct 11 ms 4308 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 22 ms 5604 KB Output is correct
9 Correct 26 ms 6008 KB Output is correct
10 Correct 2 ms 3452 KB Output is correct
11 Correct 38 ms 6936 KB Output is correct
12 Correct 56 ms 7368 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 2 ms 3436 KB Output is correct
6 Correct 3 ms 3412 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 2 ms 3436 KB Output is correct
9 Correct 2 ms 3540 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 3 ms 3412 KB Output is correct
14 Correct 2 ms 3412 KB Output is correct
15 Correct 3 ms 3432 KB Output is correct
16 Correct 2 ms 3412 KB Output is correct
17 Correct 2 ms 3412 KB Output is correct
18 Correct 2 ms 3412 KB Output is correct
19 Correct 2 ms 3412 KB Output is correct
20 Correct 2 ms 3412 KB Output is correct
21 Correct 2 ms 3412 KB Output is correct
22 Correct 2 ms 3412 KB Output is correct
23 Correct 3 ms 3412 KB Output is correct
24 Correct 2 ms 3412 KB Output is correct
25 Correct 3 ms 3436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 7500 KB Output is correct
2 Correct 39 ms 7524 KB Output is correct
3 Correct 25 ms 6148 KB Output is correct
4 Correct 7 ms 4084 KB Output is correct
5 Correct 6 ms 3920 KB Output is correct
6 Correct 11 ms 4308 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 22 ms 5604 KB Output is correct
9 Correct 26 ms 6008 KB Output is correct
10 Correct 2 ms 3452 KB Output is correct
11 Correct 38 ms 6936 KB Output is correct
12 Correct 56 ms 7368 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
14 Correct 2 ms 3412 KB Output is correct
15 Correct 2 ms 3412 KB Output is correct
16 Correct 2 ms 3412 KB Output is correct
17 Correct 2 ms 3412 KB Output is correct
18 Correct 2 ms 3436 KB Output is correct
19 Correct 3 ms 3412 KB Output is correct
20 Correct 2 ms 3412 KB Output is correct
21 Correct 2 ms 3436 KB Output is correct
22 Correct 2 ms 3540 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 3 ms 3412 KB Output is correct
27 Correct 2 ms 3412 KB Output is correct
28 Correct 3 ms 3432 KB Output is correct
29 Correct 2 ms 3412 KB Output is correct
30 Correct 2 ms 3412 KB Output is correct
31 Correct 2 ms 3412 KB Output is correct
32 Correct 2 ms 3412 KB Output is correct
33 Correct 2 ms 3412 KB Output is correct
34 Correct 2 ms 3412 KB Output is correct
35 Correct 2 ms 3412 KB Output is correct
36 Correct 3 ms 3412 KB Output is correct
37 Correct 2 ms 3412 KB Output is correct
38 Correct 3 ms 3436 KB Output is correct
39 Correct 37 ms 7884 KB Output is correct
40 Correct 39 ms 7816 KB Output is correct
41 Correct 32 ms 6420 KB Output is correct
42 Correct 9 ms 4180 KB Output is correct
43 Correct 2 ms 3440 KB Output is correct
44 Correct 3 ms 3412 KB Output is correct
45 Correct 2 ms 3540 KB Output is correct
46 Correct 2 ms 3436 KB Output is correct
47 Correct 2 ms 3412 KB Output is correct
48 Correct 2 ms 3412 KB Output is correct
49 Correct 2 ms 3412 KB Output is correct
50 Correct 2 ms 3412 KB Output is correct
51 Correct 2 ms 3436 KB Output is correct
52 Correct 2 ms 3412 KB Output is correct
53 Correct 2 ms 3412 KB Output is correct
54 Correct 2 ms 3468 KB Output is correct
55 Correct 2 ms 3412 KB Output is correct
56 Correct 2 ms 3412 KB Output is correct
57 Correct 93 ms 9176 KB Output is correct
58 Correct 89 ms 9136 KB Output is correct
59 Correct 77 ms 8972 KB Output is correct
60 Correct 89 ms 9012 KB Output is correct
61 Correct 65 ms 9020 KB Output is correct
62 Correct 68 ms 9004 KB Output is correct
63 Correct 56 ms 8812 KB Output is correct
64 Correct 55 ms 8780 KB Output is correct
65 Correct 68 ms 8868 KB Output is correct
66 Correct 69 ms 8860 KB Output is correct
67 Correct 68 ms 8908 KB Output is correct
68 Correct 62 ms 9016 KB Output is correct
69 Correct 94 ms 9012 KB Output is correct
70 Correct 99 ms 9016 KB Output is correct
71 Correct 3 ms 3412 KB Output is correct
72 Correct 4 ms 3668 KB Output is correct
73 Correct 4 ms 3572 KB Output is correct
74 Correct 3 ms 3576 KB Output is correct
75 Correct 3 ms 3668 KB Output is correct
76 Correct 4 ms 3572 KB Output is correct
77 Correct 4 ms 3668 KB Output is correct
78 Correct 4 ms 3572 KB Output is correct
79 Correct 5 ms 3616 KB Output is correct
80 Correct 65 ms 9008 KB Output is correct
81 Correct 70 ms 9008 KB Output is correct
82 Correct 77 ms 9020 KB Output is correct
83 Correct 71 ms 9004 KB Output is correct
84 Correct 3 ms 3576 KB Output is correct
85 Correct 3 ms 3524 KB Output is correct
86 Correct 3 ms 3540 KB Output is correct
87 Correct 5 ms 3540 KB Output is correct
88 Correct 3 ms 3540 KB Output is correct
89 Correct 3 ms 3540 KB Output is correct
90 Correct 4 ms 3540 KB Output is correct
91 Correct 4 ms 3612 KB Output is correct
92 Correct 3 ms 3616 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 3 ms 3412 KB Output is correct
97 Correct 3 ms 3436 KB Output is correct
98 Correct 3 ms 3412 KB Output is correct
99 Correct 3 ms 3412 KB Output is correct
100 Correct 3 ms 3436 KB Output is correct
101 Correct 3 ms 3464 KB Output is correct
102 Correct 4 ms 3412 KB Output is correct
103 Correct 3 ms 3412 KB Output is correct
104 Correct 8 ms 3920 KB Output is correct
105 Correct 14 ms 4616 KB Output is correct
106 Correct 3 ms 3412 KB Output is correct
107 Correct 32 ms 5732 KB Output is correct
108 Correct 45 ms 6056 KB Output is correct
109 Correct 3 ms 3412 KB Output is correct
110 Correct 95 ms 6876 KB Output is correct
111 Correct 63 ms 7436 KB Output is correct
112 Correct 2 ms 3412 KB Output is correct
113 Correct 77 ms 8268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1082 ms 6212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 2 ms 3436 KB Output is correct
6 Correct 3 ms 3412 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 2 ms 3436 KB Output is correct
9 Correct 2 ms 3540 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 3 ms 3412 KB Output is correct
14 Correct 2 ms 3412 KB Output is correct
15 Correct 3 ms 3432 KB Output is correct
16 Correct 2 ms 3412 KB Output is correct
17 Correct 2 ms 3412 KB Output is correct
18 Correct 2 ms 3412 KB Output is correct
19 Correct 2 ms 3412 KB Output is correct
20 Correct 2 ms 3412 KB Output is correct
21 Correct 2 ms 3412 KB Output is correct
22 Correct 2 ms 3412 KB Output is correct
23 Correct 3 ms 3412 KB Output is correct
24 Correct 2 ms 3412 KB Output is correct
25 Correct 3 ms 3436 KB Output is correct
26 Correct 9 ms 3412 KB Output is correct
27 Correct 19 ms 3572 KB Output is correct
28 Correct 24 ms 3648 KB Output is correct
29 Correct 7 ms 3448 KB Output is correct
30 Correct 15 ms 3548 KB Output is correct
31 Correct 21 ms 3668 KB Output is correct
32 Correct 6 ms 3540 KB Output is correct
33 Correct 13 ms 3600 KB Output is correct
34 Correct 19 ms 3652 KB Output is correct
35 Correct 2 ms 3412 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 3432 KB Output is correct
39 Correct 2 ms 3412 KB Output is correct
40 Correct 4 ms 3412 KB Output is correct
41 Correct 4 ms 3440 KB Output is correct
42 Correct 3 ms 3412 KB Output is correct
43 Correct 2 ms 3412 KB Output is correct
44 Correct 2 ms 3412 KB Output is correct
45 Correct 3 ms 3412 KB Output is correct
46 Correct 2 ms 3432 KB Output is correct
47 Correct 3 ms 3412 KB Output is correct
48 Correct 2 ms 3412 KB Output is correct
49 Correct 2 ms 3412 KB Output is correct
50 Correct 2 ms 3412 KB Output is correct
51 Correct 2 ms 3412 KB Output is correct
52 Correct 2 ms 3432 KB Output is correct
53 Correct 2 ms 3412 KB Output is correct
54 Correct 3 ms 3540 KB Output is correct
55 Correct 3 ms 3540 KB Output is correct
56 Correct 71 ms 3540 KB Output is correct
57 Correct 107 ms 3516 KB Output is correct
58 Correct 4 ms 3576 KB Output is correct
59 Correct 4 ms 3668 KB Output is correct
60 Correct 95 ms 3560 KB Output is correct
61 Correct 108 ms 3584 KB Output is correct
62 Correct 4 ms 3576 KB Output is correct
63 Correct 5 ms 3572 KB Output is correct
64 Correct 146 ms 3532 KB Output is correct
65 Correct 75 ms 3600 KB Output is correct
66 Correct 4 ms 3668 KB Output is correct
67 Correct 4 ms 3668 KB Output is correct
68 Correct 49 ms 3620 KB Output is correct
69 Correct 42 ms 3660 KB Output is correct
70 Correct 88 ms 3560 KB Output is correct
71 Correct 108 ms 3548 KB Output is correct
72 Correct 4 ms 3580 KB Output is correct
73 Correct 3 ms 3572 KB Output is correct
74 Correct 12 ms 3660 KB Output is correct
75 Correct 9 ms 3668 KB Output is correct
76 Correct 3 ms 3576 KB Output is correct
77 Correct 4 ms 3668 KB Output is correct
78 Correct 90 ms 3676 KB Output is correct
79 Correct 85 ms 3540 KB Output is correct
80 Correct 125 ms 3532 KB Output is correct
81 Correct 140 ms 3496 KB Output is correct
82 Correct 19 ms 3628 KB Output is correct
83 Correct 23 ms 3540 KB Output is correct
84 Correct 104 ms 3660 KB Output is correct
85 Correct 122 ms 3484 KB Output is correct
86 Correct 62 ms 3592 KB Output is correct
87 Correct 20 ms 3668 KB Output is correct
88 Correct 62 ms 3608 KB Output is correct
89 Correct 60 ms 3600 KB Output is correct
90 Correct 74 ms 3564 KB Output is correct
91 Correct 99 ms 3568 KB Output is correct
92 Correct 3 ms 3572 KB Output is correct
93 Correct 4 ms 3580 KB Output is correct
94 Correct 3 ms 3540 KB Output is correct
95 Correct 3 ms 3540 KB Output is correct
96 Correct 3 ms 3540 KB Output is correct
97 Correct 3 ms 3540 KB Output is correct
98 Correct 3 ms 3656 KB Output is correct
99 Correct 4 ms 3540 KB Output is correct
100 Correct 4 ms 3576 KB Output is correct
101 Correct 3 ms 3540 KB Output is correct
102 Correct 2 ms 3440 KB Output is correct
103 Correct 4 ms 3412 KB Output is correct
104 Correct 2 ms 3412 KB Output is correct
105 Correct 3 ms 3368 KB Output is correct
106 Correct 2 ms 3412 KB Output is correct
107 Correct 2 ms 3412 KB Output is correct
108 Correct 2 ms 3412 KB Output is correct
109 Correct 2 ms 3412 KB Output is correct
110 Correct 2 ms 3412 KB Output is correct
111 Correct 2 ms 3412 KB Output is correct
112 Correct 2 ms 3432 KB Output is correct
113 Correct 2 ms 3432 KB Output is correct
114 Correct 3 ms 3448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 7500 KB Output is correct
2 Correct 39 ms 7524 KB Output is correct
3 Correct 25 ms 6148 KB Output is correct
4 Correct 7 ms 4084 KB Output is correct
5 Correct 6 ms 3920 KB Output is correct
6 Correct 11 ms 4308 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 22 ms 5604 KB Output is correct
9 Correct 26 ms 6008 KB Output is correct
10 Correct 2 ms 3452 KB Output is correct
11 Correct 38 ms 6936 KB Output is correct
12 Correct 56 ms 7368 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
14 Correct 2 ms 3412 KB Output is correct
15 Correct 2 ms 3412 KB Output is correct
16 Correct 2 ms 3412 KB Output is correct
17 Correct 2 ms 3412 KB Output is correct
18 Correct 2 ms 3436 KB Output is correct
19 Correct 3 ms 3412 KB Output is correct
20 Correct 2 ms 3412 KB Output is correct
21 Correct 2 ms 3436 KB Output is correct
22 Correct 2 ms 3540 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 3 ms 3412 KB Output is correct
27 Correct 2 ms 3412 KB Output is correct
28 Correct 3 ms 3432 KB Output is correct
29 Correct 2 ms 3412 KB Output is correct
30 Correct 2 ms 3412 KB Output is correct
31 Correct 2 ms 3412 KB Output is correct
32 Correct 2 ms 3412 KB Output is correct
33 Correct 2 ms 3412 KB Output is correct
34 Correct 2 ms 3412 KB Output is correct
35 Correct 2 ms 3412 KB Output is correct
36 Correct 3 ms 3412 KB Output is correct
37 Correct 2 ms 3412 KB Output is correct
38 Correct 3 ms 3436 KB Output is correct
39 Correct 37 ms 7884 KB Output is correct
40 Correct 39 ms 7816 KB Output is correct
41 Correct 32 ms 6420 KB Output is correct
42 Correct 9 ms 4180 KB Output is correct
43 Correct 2 ms 3440 KB Output is correct
44 Correct 3 ms 3412 KB Output is correct
45 Correct 2 ms 3540 KB Output is correct
46 Correct 2 ms 3436 KB Output is correct
47 Correct 2 ms 3412 KB Output is correct
48 Correct 2 ms 3412 KB Output is correct
49 Correct 2 ms 3412 KB Output is correct
50 Correct 2 ms 3412 KB Output is correct
51 Correct 2 ms 3436 KB Output is correct
52 Correct 2 ms 3412 KB Output is correct
53 Correct 2 ms 3412 KB Output is correct
54 Correct 2 ms 3468 KB Output is correct
55 Correct 2 ms 3412 KB Output is correct
56 Correct 2 ms 3412 KB Output is correct
57 Correct 93 ms 9176 KB Output is correct
58 Correct 89 ms 9136 KB Output is correct
59 Correct 77 ms 8972 KB Output is correct
60 Correct 89 ms 9012 KB Output is correct
61 Correct 65 ms 9020 KB Output is correct
62 Correct 68 ms 9004 KB Output is correct
63 Correct 56 ms 8812 KB Output is correct
64 Correct 55 ms 8780 KB Output is correct
65 Correct 68 ms 8868 KB Output is correct
66 Correct 69 ms 8860 KB Output is correct
67 Correct 68 ms 8908 KB Output is correct
68 Correct 62 ms 9016 KB Output is correct
69 Correct 94 ms 9012 KB Output is correct
70 Correct 99 ms 9016 KB Output is correct
71 Correct 3 ms 3412 KB Output is correct
72 Correct 4 ms 3668 KB Output is correct
73 Correct 4 ms 3572 KB Output is correct
74 Correct 3 ms 3576 KB Output is correct
75 Correct 3 ms 3668 KB Output is correct
76 Correct 4 ms 3572 KB Output is correct
77 Correct 4 ms 3668 KB Output is correct
78 Correct 4 ms 3572 KB Output is correct
79 Correct 5 ms 3616 KB Output is correct
80 Correct 65 ms 9008 KB Output is correct
81 Correct 70 ms 9008 KB Output is correct
82 Correct 77 ms 9020 KB Output is correct
83 Correct 71 ms 9004 KB Output is correct
84 Correct 3 ms 3576 KB Output is correct
85 Correct 3 ms 3524 KB Output is correct
86 Correct 3 ms 3540 KB Output is correct
87 Correct 5 ms 3540 KB Output is correct
88 Correct 3 ms 3540 KB Output is correct
89 Correct 3 ms 3540 KB Output is correct
90 Correct 4 ms 3540 KB Output is correct
91 Correct 4 ms 3612 KB Output is correct
92 Correct 3 ms 3616 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 3 ms 3412 KB Output is correct
97 Correct 3 ms 3436 KB Output is correct
98 Correct 3 ms 3412 KB Output is correct
99 Correct 3 ms 3412 KB Output is correct
100 Correct 3 ms 3436 KB Output is correct
101 Correct 3 ms 3464 KB Output is correct
102 Correct 4 ms 3412 KB Output is correct
103 Correct 3 ms 3412 KB Output is correct
104 Correct 8 ms 3920 KB Output is correct
105 Correct 14 ms 4616 KB Output is correct
106 Correct 3 ms 3412 KB Output is correct
107 Correct 32 ms 5732 KB Output is correct
108 Correct 45 ms 6056 KB Output is correct
109 Correct 3 ms 3412 KB Output is correct
110 Correct 95 ms 6876 KB Output is correct
111 Correct 63 ms 7436 KB Output is correct
112 Correct 2 ms 3412 KB Output is correct
113 Correct 77 ms 8268 KB Output is correct
114 Execution timed out 1082 ms 6212 KB Time limit exceeded
115 Halted 0 ms 0 KB -