Submission #829214

# Submission time Handle Problem Language Result Execution time Memory
829214 2023-08-18T06:40:05 Z bachhoangxuan Dreaming (IOI13_dreaming) C++17
47 / 100
51 ms 18700 KB
#include "dreaming.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
const int inf=1e9;
#define pii pair<int,int>
#define fi first
#define se second
vector<pii> edge[maxn];
int Max[maxn],d[maxn],res;
bool vis[maxn];

void dfs(int u,int p){
    vis[u]=true;
    for(auto [v,w]:edge[u]){
        if(v==p) continue;
        dfs(v,u);
        if(Max[v]+w>Max[u]){
            d[u]=Max[u];
            Max[u]=Max[v]+w;
        }
        else if(Max[v]+w>d[u]) d[u]=Max[v]+w;
    }
    res=max(res,Max[u]+d[u]);
}
int Min=inf;
void redfs(int u,int p,int t){
    for(auto [v,w]:edge[u]){
        if(v==p) continue;
        int nxt=max(t,(Max[v]+w==Max[u]?d[u]:Max[u]))+w;
        redfs(v,u,nxt);
    }
    Max[u]=max(Max[u],t);
    Min=min(Min,Max[u]);
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    for(int i=0;i<M;i++){
        edge[A[i]].push_back({B[i],T[i]});
        edge[B[i]].push_back({A[i],T[i]});
    }
    priority_queue<int,vector<int>,greater<int>> pq;
    for(int i=0;i<N;i++){
        if(!vis[i]){
            dfs(i,0);Min=inf;
            redfs(i,0,0);
            pq.push(Min);
        }
    }
    while((int)pq.size()>=2){
        int x=pq.top();pq.pop();
        int y=pq.top();pq.pop();
        res=max(res,x+y+L);
        pq.push(max(x+L,y));
    }
    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 35 ms 13288 KB Output is correct
2 Correct 33 ms 12972 KB Output is correct
3 Correct 23 ms 11460 KB Output is correct
4 Correct 5 ms 4204 KB Output is correct
5 Correct 5 ms 3488 KB Output is correct
6 Correct 10 ms 4948 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 18 ms 7032 KB Output is correct
9 Correct 20 ms 9620 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 29 ms 10544 KB Output is correct
12 Correct 32 ms 11724 KB Output is correct
13 Correct 2 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2772 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 2 ms 2664 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2656 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2660 KB Output is correct
14 Correct 1 ms 2660 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 1 ms 2656 KB Output is correct
17 Correct 1 ms 2660 KB Output is correct
18 Correct 1 ms 2664 KB Output is correct
19 Correct 1 ms 2612 KB Output is correct
20 Correct 1 ms 2644 KB Output is correct
21 Correct 1 ms 2644 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 1 ms 2644 KB Output is correct
24 Correct 1 ms 2644 KB Output is correct
25 Correct 1 ms 2660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 13288 KB Output is correct
2 Correct 33 ms 12972 KB Output is correct
3 Correct 23 ms 11460 KB Output is correct
4 Correct 5 ms 4204 KB Output is correct
5 Correct 5 ms 3488 KB Output is correct
6 Correct 10 ms 4948 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 18 ms 7032 KB Output is correct
9 Correct 20 ms 9620 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 29 ms 10544 KB Output is correct
12 Correct 32 ms 11724 KB Output is correct
13 Correct 2 ms 2772 KB Output is correct
14 Correct 2 ms 2772 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 1 ms 2644 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 1 ms 2644 KB Output is correct
19 Correct 2 ms 2664 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 2656 KB Output is correct
25 Correct 1 ms 2644 KB Output is correct
26 Correct 1 ms 2660 KB Output is correct
27 Correct 1 ms 2660 KB Output is correct
28 Correct 1 ms 2644 KB Output is correct
29 Correct 1 ms 2656 KB Output is correct
30 Correct 1 ms 2660 KB Output is correct
31 Correct 1 ms 2664 KB Output is correct
32 Correct 1 ms 2612 KB Output is correct
33 Correct 1 ms 2644 KB Output is correct
34 Correct 1 ms 2644 KB Output is correct
35 Correct 1 ms 2652 KB Output is correct
36 Correct 1 ms 2644 KB Output is correct
37 Correct 1 ms 2644 KB Output is correct
38 Correct 1 ms 2660 KB Output is correct
39 Correct 30 ms 13260 KB Output is correct
40 Correct 36 ms 12872 KB Output is correct
41 Correct 30 ms 11504 KB Output is correct
42 Correct 7 ms 4204 KB Output is correct
43 Correct 2 ms 2688 KB Output is correct
44 Correct 1 ms 2656 KB Output is correct
45 Correct 1 ms 2644 KB Output is correct
46 Correct 1 ms 2656 KB Output is correct
47 Correct 1 ms 2644 KB Output is correct
48 Correct 1 ms 2644 KB Output is correct
49 Correct 1 ms 2644 KB Output is correct
50 Correct 1 ms 2660 KB Output is correct
51 Correct 2 ms 2644 KB Output is correct
52 Correct 1 ms 2644 KB Output is correct
53 Correct 1 ms 2644 KB Output is correct
54 Correct 1 ms 2644 KB Output is correct
55 Correct 1 ms 2644 KB Output is correct
56 Correct 1 ms 2592 KB Output is correct
57 Correct 44 ms 9932 KB Output is correct
58 Correct 38 ms 9932 KB Output is correct
59 Correct 38 ms 9960 KB Output is correct
60 Correct 38 ms 9932 KB Output is correct
61 Correct 39 ms 9980 KB Output is correct
62 Correct 37 ms 10060 KB Output is correct
63 Correct 35 ms 9716 KB Output is correct
64 Correct 37 ms 9732 KB Output is correct
65 Correct 37 ms 9976 KB Output is correct
66 Correct 51 ms 10016 KB Output is correct
67 Correct 38 ms 9932 KB Output is correct
68 Correct 37 ms 9940 KB Output is correct
69 Correct 39 ms 10216 KB Output is correct
70 Correct 39 ms 10204 KB Output is correct
71 Correct 1 ms 2644 KB Output is correct
72 Correct 2 ms 2900 KB Output is correct
73 Correct 3 ms 2796 KB Output is correct
74 Correct 2 ms 2772 KB Output is correct
75 Correct 2 ms 2772 KB Output is correct
76 Correct 2 ms 2772 KB Output is correct
77 Correct 2 ms 2900 KB Output is correct
78 Correct 2 ms 2804 KB Output is correct
79 Correct 3 ms 2804 KB Output is correct
80 Correct 39 ms 9892 KB Output is correct
81 Correct 39 ms 9948 KB Output is correct
82 Correct 38 ms 10024 KB Output is correct
83 Correct 37 ms 10064 KB Output is correct
84 Correct 2 ms 2772 KB Output is correct
85 Correct 2 ms 2796 KB Output is correct
86 Correct 2 ms 2772 KB Output is correct
87 Correct 2 ms 2796 KB Output is correct
88 Correct 2 ms 2800 KB Output is correct
89 Correct 2 ms 2800 KB Output is correct
90 Correct 2 ms 2772 KB Output is correct
91 Correct 2 ms 2772 KB Output is correct
92 Correct 2 ms 2772 KB Output is correct
93 Correct 2 ms 2772 KB Output is correct
94 Correct 1 ms 2660 KB Output is correct
95 Correct 1 ms 2644 KB Output is correct
96 Correct 1 ms 2644 KB Output is correct
97 Correct 1 ms 2644 KB Output is correct
98 Correct 1 ms 2644 KB Output is correct
99 Correct 1 ms 2644 KB Output is correct
100 Correct 1 ms 2644 KB Output is correct
101 Correct 1 ms 2644 KB Output is correct
102 Correct 1 ms 2656 KB Output is correct
103 Correct 1 ms 2656 KB Output is correct
104 Correct 5 ms 3500 KB Output is correct
105 Correct 11 ms 4948 KB Output is correct
106 Correct 1 ms 2644 KB Output is correct
107 Correct 20 ms 7088 KB Output is correct
108 Correct 21 ms 9548 KB Output is correct
109 Correct 1 ms 2644 KB Output is correct
110 Correct 28 ms 10444 KB Output is correct
111 Correct 31 ms 11732 KB Output is correct
112 Correct 1 ms 2772 KB Output is correct
113 Correct 45 ms 18700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 6624 KB Output is correct
2 Incorrect 21 ms 6536 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2772 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 2 ms 2664 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2656 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2660 KB Output is correct
14 Correct 1 ms 2660 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 1 ms 2656 KB Output is correct
17 Correct 1 ms 2660 KB Output is correct
18 Correct 1 ms 2664 KB Output is correct
19 Correct 1 ms 2612 KB Output is correct
20 Correct 1 ms 2644 KB Output is correct
21 Correct 1 ms 2644 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 1 ms 2644 KB Output is correct
24 Correct 1 ms 2644 KB Output is correct
25 Correct 1 ms 2660 KB Output is correct
26 Correct 1 ms 2644 KB Output is correct
27 Correct 2 ms 2772 KB Output is correct
28 Correct 2 ms 2772 KB Output is correct
29 Incorrect 1 ms 2644 KB Output isn't correct
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 35 ms 13288 KB Output is correct
2 Correct 33 ms 12972 KB Output is correct
3 Correct 23 ms 11460 KB Output is correct
4 Correct 5 ms 4204 KB Output is correct
5 Correct 5 ms 3488 KB Output is correct
6 Correct 10 ms 4948 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 18 ms 7032 KB Output is correct
9 Correct 20 ms 9620 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 29 ms 10544 KB Output is correct
12 Correct 32 ms 11724 KB Output is correct
13 Correct 2 ms 2772 KB Output is correct
14 Correct 2 ms 2772 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 1 ms 2644 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 1 ms 2644 KB Output is correct
19 Correct 2 ms 2664 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 2656 KB Output is correct
25 Correct 1 ms 2644 KB Output is correct
26 Correct 1 ms 2660 KB Output is correct
27 Correct 1 ms 2660 KB Output is correct
28 Correct 1 ms 2644 KB Output is correct
29 Correct 1 ms 2656 KB Output is correct
30 Correct 1 ms 2660 KB Output is correct
31 Correct 1 ms 2664 KB Output is correct
32 Correct 1 ms 2612 KB Output is correct
33 Correct 1 ms 2644 KB Output is correct
34 Correct 1 ms 2644 KB Output is correct
35 Correct 1 ms 2652 KB Output is correct
36 Correct 1 ms 2644 KB Output is correct
37 Correct 1 ms 2644 KB Output is correct
38 Correct 1 ms 2660 KB Output is correct
39 Correct 30 ms 13260 KB Output is correct
40 Correct 36 ms 12872 KB Output is correct
41 Correct 30 ms 11504 KB Output is correct
42 Correct 7 ms 4204 KB Output is correct
43 Correct 2 ms 2688 KB Output is correct
44 Correct 1 ms 2656 KB Output is correct
45 Correct 1 ms 2644 KB Output is correct
46 Correct 1 ms 2656 KB Output is correct
47 Correct 1 ms 2644 KB Output is correct
48 Correct 1 ms 2644 KB Output is correct
49 Correct 1 ms 2644 KB Output is correct
50 Correct 1 ms 2660 KB Output is correct
51 Correct 2 ms 2644 KB Output is correct
52 Correct 1 ms 2644 KB Output is correct
53 Correct 1 ms 2644 KB Output is correct
54 Correct 1 ms 2644 KB Output is correct
55 Correct 1 ms 2644 KB Output is correct
56 Correct 1 ms 2592 KB Output is correct
57 Correct 44 ms 9932 KB Output is correct
58 Correct 38 ms 9932 KB Output is correct
59 Correct 38 ms 9960 KB Output is correct
60 Correct 38 ms 9932 KB Output is correct
61 Correct 39 ms 9980 KB Output is correct
62 Correct 37 ms 10060 KB Output is correct
63 Correct 35 ms 9716 KB Output is correct
64 Correct 37 ms 9732 KB Output is correct
65 Correct 37 ms 9976 KB Output is correct
66 Correct 51 ms 10016 KB Output is correct
67 Correct 38 ms 9932 KB Output is correct
68 Correct 37 ms 9940 KB Output is correct
69 Correct 39 ms 10216 KB Output is correct
70 Correct 39 ms 10204 KB Output is correct
71 Correct 1 ms 2644 KB Output is correct
72 Correct 2 ms 2900 KB Output is correct
73 Correct 3 ms 2796 KB Output is correct
74 Correct 2 ms 2772 KB Output is correct
75 Correct 2 ms 2772 KB Output is correct
76 Correct 2 ms 2772 KB Output is correct
77 Correct 2 ms 2900 KB Output is correct
78 Correct 2 ms 2804 KB Output is correct
79 Correct 3 ms 2804 KB Output is correct
80 Correct 39 ms 9892 KB Output is correct
81 Correct 39 ms 9948 KB Output is correct
82 Correct 38 ms 10024 KB Output is correct
83 Correct 37 ms 10064 KB Output is correct
84 Correct 2 ms 2772 KB Output is correct
85 Correct 2 ms 2796 KB Output is correct
86 Correct 2 ms 2772 KB Output is correct
87 Correct 2 ms 2796 KB Output is correct
88 Correct 2 ms 2800 KB Output is correct
89 Correct 2 ms 2800 KB Output is correct
90 Correct 2 ms 2772 KB Output is correct
91 Correct 2 ms 2772 KB Output is correct
92 Correct 2 ms 2772 KB Output is correct
93 Correct 2 ms 2772 KB Output is correct
94 Correct 1 ms 2660 KB Output is correct
95 Correct 1 ms 2644 KB Output is correct
96 Correct 1 ms 2644 KB Output is correct
97 Correct 1 ms 2644 KB Output is correct
98 Correct 1 ms 2644 KB Output is correct
99 Correct 1 ms 2644 KB Output is correct
100 Correct 1 ms 2644 KB Output is correct
101 Correct 1 ms 2644 KB Output is correct
102 Correct 1 ms 2656 KB Output is correct
103 Correct 1 ms 2656 KB Output is correct
104 Correct 5 ms 3500 KB Output is correct
105 Correct 11 ms 4948 KB Output is correct
106 Correct 1 ms 2644 KB Output is correct
107 Correct 20 ms 7088 KB Output is correct
108 Correct 21 ms 9548 KB Output is correct
109 Correct 1 ms 2644 KB Output is correct
110 Correct 28 ms 10444 KB Output is correct
111 Correct 31 ms 11732 KB Output is correct
112 Correct 1 ms 2772 KB Output is correct
113 Correct 45 ms 18700 KB Output is correct
114 Correct 26 ms 6624 KB Output is correct
115 Incorrect 21 ms 6536 KB Output isn't correct
116 Halted 0 ms 0 KB -