답안 #727107

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
727107 2023-04-20T04:06:15 Z hoainiem 꿈 (IOI13_dreaming) C++14
47 / 100
1000 ms 8876 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];
        }
    if (M == N - 2)
        return max(diameter, a[2] + a[1] + L);
    return 0;
    sf[d + 1] = {-inf, -inf};
    for (int i = d; i > 0; i--)
        sf[i] = sf[i + 1] + a[i];
    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 45 ms 7596 KB Output is correct
2 Correct 58 ms 7540 KB Output is correct
3 Correct 28 ms 6140 KB Output is correct
4 Correct 8 ms 4052 KB Output is correct
5 Correct 6 ms 3796 KB Output is correct
6 Correct 13 ms 4308 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 29 ms 5248 KB Output is correct
9 Correct 27 ms 5712 KB Output is correct
10 Correct 3 ms 3412 KB Output is correct
11 Correct 40 ms 6608 KB Output is correct
12 Correct 48 ms 7052 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 3 ms 3412 KB Output is correct
4 Correct 3 ms 3412 KB Output is correct
5 Correct 2 ms 3476 KB Output is correct
6 Correct 3 ms 3412 KB Output is correct
7 Correct 3 ms 3412 KB Output is correct
8 Correct 2 ms 3412 KB Output is correct
9 Correct 2 ms 3412 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 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 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 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
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 7596 KB Output is correct
2 Correct 58 ms 7540 KB Output is correct
3 Correct 28 ms 6140 KB Output is correct
4 Correct 8 ms 4052 KB Output is correct
5 Correct 6 ms 3796 KB Output is correct
6 Correct 13 ms 4308 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 29 ms 5248 KB Output is correct
9 Correct 27 ms 5712 KB Output is correct
10 Correct 3 ms 3412 KB Output is correct
11 Correct 40 ms 6608 KB Output is correct
12 Correct 48 ms 7052 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 3 ms 3412 KB Output is correct
17 Correct 3 ms 3412 KB Output is correct
18 Correct 2 ms 3476 KB Output is correct
19 Correct 3 ms 3412 KB Output is correct
20 Correct 3 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 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 3412 KB Output is correct
28 Correct 2 ms 3412 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 2 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 7508 KB Output is correct
40 Correct 36 ms 7500 KB Output is correct
41 Correct 30 ms 6060 KB Output is correct
42 Correct 7 ms 4072 KB Output is correct
43 Correct 2 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 3412 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 3412 KB Output is correct
52 Correct 2 ms 3412 KB Output is correct
53 Correct 2 ms 3480 KB Output is correct
54 Correct 2 ms 3412 KB Output is correct
55 Correct 2 ms 3412 KB Output is correct
56 Correct 2 ms 3412 KB Output is correct
57 Correct 63 ms 8692 KB Output is correct
58 Correct 86 ms 8684 KB Output is correct
59 Correct 95 ms 8876 KB Output is correct
60 Correct 84 ms 8540 KB Output is correct
61 Correct 61 ms 8724 KB Output is correct
62 Correct 59 ms 8580 KB Output is correct
63 Correct 62 ms 8396 KB Output is correct
64 Correct 77 ms 8396 KB Output is correct
65 Correct 83 ms 8532 KB Output is correct
66 Correct 80 ms 8376 KB Output is correct
67 Correct 91 ms 8628 KB Output is correct
68 Correct 86 ms 8528 KB Output is correct
69 Correct 86 ms 8564 KB Output is correct
70 Correct 68 ms 8580 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 3540 KB Output is correct
74 Correct 3 ms 3584 KB Output is correct
75 Correct 3 ms 3540 KB Output is correct
76 Correct 3 ms 3540 KB Output is correct
77 Correct 4 ms 3540 KB Output is correct
78 Correct 3 ms 3540 KB Output is correct
79 Correct 4 ms 3540 KB Output is correct
80 Correct 87 ms 8524 KB Output is correct
81 Correct 78 ms 8588 KB Output is correct
82 Correct 64 ms 8612 KB Output is correct
83 Correct 83 ms 8620 KB Output is correct
84 Correct 3 ms 3540 KB Output is correct
85 Correct 4 ms 3540 KB Output is correct
86 Correct 4 ms 3540 KB Output is correct
87 Correct 4 ms 3592 KB Output is correct
88 Correct 3 ms 3616 KB Output is correct
89 Correct 3 ms 3492 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 3540 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 2 ms 3412 KB Output is correct
98 Correct 3 ms 3412 KB Output is correct
99 Correct 2 ms 3412 KB Output is correct
100 Correct 2 ms 3412 KB Output is correct
101 Correct 2 ms 3412 KB Output is correct
102 Correct 2 ms 3412 KB Output is correct
103 Correct 2 ms 3412 KB Output is correct
104 Correct 6 ms 3796 KB Output is correct
105 Correct 11 ms 4308 KB Output is correct
106 Correct 2 ms 3412 KB Output is correct
107 Correct 29 ms 5248 KB Output is correct
108 Correct 34 ms 5636 KB Output is correct
109 Correct 3 ms 3412 KB Output is correct
110 Correct 40 ms 6484 KB Output is correct
111 Correct 52 ms 6988 KB Output is correct
112 Correct 2 ms 3412 KB Output is correct
113 Correct 73 ms 7884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1087 ms 6104 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 3 ms 3412 KB Output is correct
4 Correct 3 ms 3412 KB Output is correct
5 Correct 2 ms 3476 KB Output is correct
6 Correct 3 ms 3412 KB Output is correct
7 Correct 3 ms 3412 KB Output is correct
8 Correct 2 ms 3412 KB Output is correct
9 Correct 2 ms 3412 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 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 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 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 Incorrect 8 ms 3412 KB Output isn't correct
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 7596 KB Output is correct
2 Correct 58 ms 7540 KB Output is correct
3 Correct 28 ms 6140 KB Output is correct
4 Correct 8 ms 4052 KB Output is correct
5 Correct 6 ms 3796 KB Output is correct
6 Correct 13 ms 4308 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 29 ms 5248 KB Output is correct
9 Correct 27 ms 5712 KB Output is correct
10 Correct 3 ms 3412 KB Output is correct
11 Correct 40 ms 6608 KB Output is correct
12 Correct 48 ms 7052 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 3 ms 3412 KB Output is correct
17 Correct 3 ms 3412 KB Output is correct
18 Correct 2 ms 3476 KB Output is correct
19 Correct 3 ms 3412 KB Output is correct
20 Correct 3 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 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 3412 KB Output is correct
28 Correct 2 ms 3412 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 2 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 7508 KB Output is correct
40 Correct 36 ms 7500 KB Output is correct
41 Correct 30 ms 6060 KB Output is correct
42 Correct 7 ms 4072 KB Output is correct
43 Correct 2 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 3412 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 3412 KB Output is correct
52 Correct 2 ms 3412 KB Output is correct
53 Correct 2 ms 3480 KB Output is correct
54 Correct 2 ms 3412 KB Output is correct
55 Correct 2 ms 3412 KB Output is correct
56 Correct 2 ms 3412 KB Output is correct
57 Correct 63 ms 8692 KB Output is correct
58 Correct 86 ms 8684 KB Output is correct
59 Correct 95 ms 8876 KB Output is correct
60 Correct 84 ms 8540 KB Output is correct
61 Correct 61 ms 8724 KB Output is correct
62 Correct 59 ms 8580 KB Output is correct
63 Correct 62 ms 8396 KB Output is correct
64 Correct 77 ms 8396 KB Output is correct
65 Correct 83 ms 8532 KB Output is correct
66 Correct 80 ms 8376 KB Output is correct
67 Correct 91 ms 8628 KB Output is correct
68 Correct 86 ms 8528 KB Output is correct
69 Correct 86 ms 8564 KB Output is correct
70 Correct 68 ms 8580 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 3540 KB Output is correct
74 Correct 3 ms 3584 KB Output is correct
75 Correct 3 ms 3540 KB Output is correct
76 Correct 3 ms 3540 KB Output is correct
77 Correct 4 ms 3540 KB Output is correct
78 Correct 3 ms 3540 KB Output is correct
79 Correct 4 ms 3540 KB Output is correct
80 Correct 87 ms 8524 KB Output is correct
81 Correct 78 ms 8588 KB Output is correct
82 Correct 64 ms 8612 KB Output is correct
83 Correct 83 ms 8620 KB Output is correct
84 Correct 3 ms 3540 KB Output is correct
85 Correct 4 ms 3540 KB Output is correct
86 Correct 4 ms 3540 KB Output is correct
87 Correct 4 ms 3592 KB Output is correct
88 Correct 3 ms 3616 KB Output is correct
89 Correct 3 ms 3492 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 3540 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 2 ms 3412 KB Output is correct
98 Correct 3 ms 3412 KB Output is correct
99 Correct 2 ms 3412 KB Output is correct
100 Correct 2 ms 3412 KB Output is correct
101 Correct 2 ms 3412 KB Output is correct
102 Correct 2 ms 3412 KB Output is correct
103 Correct 2 ms 3412 KB Output is correct
104 Correct 6 ms 3796 KB Output is correct
105 Correct 11 ms 4308 KB Output is correct
106 Correct 2 ms 3412 KB Output is correct
107 Correct 29 ms 5248 KB Output is correct
108 Correct 34 ms 5636 KB Output is correct
109 Correct 3 ms 3412 KB Output is correct
110 Correct 40 ms 6484 KB Output is correct
111 Correct 52 ms 6988 KB Output is correct
112 Correct 2 ms 3412 KB Output is correct
113 Correct 73 ms 7884 KB Output is correct
114 Execution timed out 1087 ms 6104 KB Time limit exceeded
115 Halted 0 ms 0 KB -