Submission #452136

# Submission time Handle Problem Language Result Execution time Memory
452136 2021-08-03T21:23:50 Z FEDIKUS Dreaming (IOI13_dreaming) C++17
47 / 100
110 ms 13980 KB
#include "dreaming.h"

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

using namespace std;

typedef pair<int,int> pii;

const int maxn=1e5+10;

bool bio[maxn];
int dist[maxn];
int dp[maxn];
vector<pii> g[maxn];

void dfs1(int cvor){
    if(bio[cvor]) return;
    bio[cvor]=true;
    dp[cvor]=0;
    for(pii i:g[cvor]){
        if(bio[i.xx]) continue;
        dfs1(i.xx);
        dp[cvor]=max(dp[cvor],dp[i.xx]+i.yy);
    }
}

void uradi(int cvor,int prosli){
    dp[prosli]=dp[cvor]=0;
    for(auto i:g[prosli]){
        if(i.xx==cvor) continue;
        dp[prosli]=max(dp[prosli],dp[i.xx]+i.yy);
    }
    for(auto i:g[cvor]){
        dp[cvor]=max(dp[cvor],dp[i.xx]+i.yy);
    }
}

pii dfs2(int cvor,int prosli){
    if(prosli!=-1) uradi(cvor,prosli);
    pii ret={dp[cvor],cvor};
    for(pii i:g[cvor]){
        if(i.xx==prosli) continue;
        ret=min(ret,dfs2(i.xx,cvor));
    }
    if(prosli!=-1) uradi(prosli,cvor);
    return ret;
}

pii najd(int cvor,int prosli){
    pii ret=mp(0,cvor);
    for(pii i:g[cvor]){
        if(i.xx==prosli) continue;
        pii pom=najd(i.xx,cvor);
        pom.xx+=i.yy;
        ret=max(ret,pom);
    }
    return ret;
}

int odg(int cvor){
    return najd(najd(cvor,-1).yy,-1).xx;
}

int travelTime(int n,int m,int l,int a[],int b[],int t[]) {
    for(int i=0;i<n;i++) dist[i]=-1;
    for(int i=0;i<m;i++){
        g[a[i]].pb(mp(b[i],t[i]));
        g[b[i]].pb(mp(a[i],t[i]));
    }
    priority_queue<pii,vector<pii>,greater<pii> > pq;
    for(int i=0;i<n;i++){
        if(bio[i]) continue;
        dfs1(i);
        pq.push(dfs2(i,-1));
    }
    while(pq.size()!=1){
        pii t1,t2;
        t1=pq.top(); pq.pop();
        t2=pq.top(); pq.pop();
        g[t1.yy].pb(mp(t2.yy,l));
        g[t2.yy].pb(mp(t1.yy,l));
        if(max(t1.xx,t2.xx+l)<=max(t1.xx+l,t2.xx)) pq.push(mp(max(t1.xx,t2.xx+l),t1.yy));
        else pq.push(mp(max(t1.xx+l,t2.xx),t2.yy));
    }
    return odg(0);
}
# Verdict Execution time Memory Grader output
1 Correct 81 ms 12996 KB Output is correct
2 Correct 53 ms 12952 KB Output is correct
3 Correct 40 ms 9472 KB Output is correct
4 Correct 10 ms 4172 KB Output is correct
5 Correct 7 ms 3452 KB Output is correct
6 Correct 14 ms 4940 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 27 ms 5972 KB Output is correct
9 Correct 40 ms 7620 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 64 ms 9132 KB Output is correct
12 Correct 61 ms 9296 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 2 ms 2636 KB Output is correct
12 Correct 2 ms 2636 KB Output is correct
13 Correct 3 ms 2636 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 3 ms 2636 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 2 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 12996 KB Output is correct
2 Correct 53 ms 12952 KB Output is correct
3 Correct 40 ms 9472 KB Output is correct
4 Correct 10 ms 4172 KB Output is correct
5 Correct 7 ms 3452 KB Output is correct
6 Correct 14 ms 4940 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 27 ms 5972 KB Output is correct
9 Correct 40 ms 7620 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 64 ms 9132 KB Output is correct
12 Correct 61 ms 9296 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 2 ms 2636 KB Output is correct
26 Correct 3 ms 2636 KB Output is correct
27 Correct 2 ms 2636 KB Output is correct
28 Correct 2 ms 2636 KB Output is correct
29 Correct 2 ms 2636 KB Output is correct
30 Correct 2 ms 2636 KB Output is correct
31 Correct 2 ms 2636 KB Output is correct
32 Correct 2 ms 2636 KB Output is correct
33 Correct 2 ms 2636 KB Output is correct
34 Correct 3 ms 2636 KB Output is correct
35 Correct 2 ms 2636 KB Output is correct
36 Correct 2 ms 2636 KB Output is correct
37 Correct 2 ms 2636 KB Output is correct
38 Correct 2 ms 2636 KB Output is correct
39 Correct 60 ms 12996 KB Output is correct
40 Correct 62 ms 12980 KB Output is correct
41 Correct 36 ms 9428 KB Output is correct
42 Correct 9 ms 4192 KB Output is correct
43 Correct 2 ms 2636 KB Output is correct
44 Correct 2 ms 2636 KB Output is correct
45 Correct 2 ms 2636 KB Output is correct
46 Correct 2 ms 2636 KB Output is correct
47 Correct 2 ms 2644 KB Output is correct
48 Correct 2 ms 2636 KB Output is correct
49 Correct 2 ms 2636 KB Output is correct
50 Correct 2 ms 2636 KB Output is correct
51 Correct 2 ms 2636 KB Output is correct
52 Correct 2 ms 2636 KB Output is correct
53 Correct 2 ms 2636 KB Output is correct
54 Correct 2 ms 2636 KB Output is correct
55 Correct 2 ms 2636 KB Output is correct
56 Correct 2 ms 2636 KB Output is correct
57 Correct 87 ms 8668 KB Output is correct
58 Correct 72 ms 8620 KB Output is correct
59 Correct 71 ms 8472 KB Output is correct
60 Correct 77 ms 8512 KB Output is correct
61 Correct 90 ms 8544 KB Output is correct
62 Correct 76 ms 8408 KB Output is correct
63 Correct 66 ms 8260 KB Output is correct
64 Correct 71 ms 8368 KB Output is correct
65 Correct 70 ms 8360 KB Output is correct
66 Correct 71 ms 8360 KB Output is correct
67 Correct 73 ms 8592 KB Output is correct
68 Correct 90 ms 8708 KB Output is correct
69 Correct 89 ms 8568 KB Output is correct
70 Correct 82 ms 8516 KB Output is correct
71 Correct 2 ms 2636 KB Output is correct
72 Correct 3 ms 2764 KB Output is correct
73 Correct 3 ms 2764 KB Output is correct
74 Correct 3 ms 2764 KB Output is correct
75 Correct 3 ms 2764 KB Output is correct
76 Correct 3 ms 2764 KB Output is correct
77 Correct 3 ms 2764 KB Output is correct
78 Correct 4 ms 2764 KB Output is correct
79 Correct 3 ms 2764 KB Output is correct
80 Correct 87 ms 8632 KB Output is correct
81 Correct 78 ms 8536 KB Output is correct
82 Correct 108 ms 8516 KB Output is correct
83 Correct 77 ms 8516 KB Output is correct
84 Correct 5 ms 2812 KB Output is correct
85 Correct 5 ms 2804 KB Output is correct
86 Correct 3 ms 2764 KB Output is correct
87 Correct 3 ms 2764 KB Output is correct
88 Correct 4 ms 2764 KB Output is correct
89 Correct 4 ms 2764 KB Output is correct
90 Correct 3 ms 2764 KB Output is correct
91 Correct 3 ms 2764 KB Output is correct
92 Correct 3 ms 2828 KB Output is correct
93 Correct 4 ms 2764 KB Output is correct
94 Correct 2 ms 2636 KB Output is correct
95 Correct 2 ms 2636 KB Output is correct
96 Correct 2 ms 2636 KB Output is correct
97 Correct 2 ms 2636 KB Output is correct
98 Correct 2 ms 2636 KB Output is correct
99 Correct 2 ms 2680 KB Output is correct
100 Correct 2 ms 2636 KB Output is correct
101 Correct 2 ms 2636 KB Output is correct
102 Correct 2 ms 2636 KB Output is correct
103 Correct 2 ms 2636 KB Output is correct
104 Correct 7 ms 3380 KB Output is correct
105 Correct 14 ms 4876 KB Output is correct
106 Correct 2 ms 2636 KB Output is correct
107 Correct 29 ms 5964 KB Output is correct
108 Correct 36 ms 7620 KB Output is correct
109 Correct 3 ms 2636 KB Output is correct
110 Correct 58 ms 9136 KB Output is correct
111 Correct 72 ms 9396 KB Output is correct
112 Correct 3 ms 2636 KB Output is correct
113 Correct 110 ms 13980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 8772 KB Output is correct
2 Incorrect 52 ms 8732 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 2 ms 2636 KB Output is correct
12 Correct 2 ms 2636 KB Output is correct
13 Correct 3 ms 2636 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 3 ms 2636 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 2 ms 2636 KB Output is correct
26 Correct 2 ms 2636 KB Output is correct
27 Correct 4 ms 2764 KB Output is correct
28 Correct 4 ms 2848 KB Output is correct
29 Incorrect 2 ms 2636 KB Output isn't correct
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 81 ms 12996 KB Output is correct
2 Correct 53 ms 12952 KB Output is correct
3 Correct 40 ms 9472 KB Output is correct
4 Correct 10 ms 4172 KB Output is correct
5 Correct 7 ms 3452 KB Output is correct
6 Correct 14 ms 4940 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 27 ms 5972 KB Output is correct
9 Correct 40 ms 7620 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 64 ms 9132 KB Output is correct
12 Correct 61 ms 9296 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 2 ms 2636 KB Output is correct
26 Correct 3 ms 2636 KB Output is correct
27 Correct 2 ms 2636 KB Output is correct
28 Correct 2 ms 2636 KB Output is correct
29 Correct 2 ms 2636 KB Output is correct
30 Correct 2 ms 2636 KB Output is correct
31 Correct 2 ms 2636 KB Output is correct
32 Correct 2 ms 2636 KB Output is correct
33 Correct 2 ms 2636 KB Output is correct
34 Correct 3 ms 2636 KB Output is correct
35 Correct 2 ms 2636 KB Output is correct
36 Correct 2 ms 2636 KB Output is correct
37 Correct 2 ms 2636 KB Output is correct
38 Correct 2 ms 2636 KB Output is correct
39 Correct 60 ms 12996 KB Output is correct
40 Correct 62 ms 12980 KB Output is correct
41 Correct 36 ms 9428 KB Output is correct
42 Correct 9 ms 4192 KB Output is correct
43 Correct 2 ms 2636 KB Output is correct
44 Correct 2 ms 2636 KB Output is correct
45 Correct 2 ms 2636 KB Output is correct
46 Correct 2 ms 2636 KB Output is correct
47 Correct 2 ms 2644 KB Output is correct
48 Correct 2 ms 2636 KB Output is correct
49 Correct 2 ms 2636 KB Output is correct
50 Correct 2 ms 2636 KB Output is correct
51 Correct 2 ms 2636 KB Output is correct
52 Correct 2 ms 2636 KB Output is correct
53 Correct 2 ms 2636 KB Output is correct
54 Correct 2 ms 2636 KB Output is correct
55 Correct 2 ms 2636 KB Output is correct
56 Correct 2 ms 2636 KB Output is correct
57 Correct 87 ms 8668 KB Output is correct
58 Correct 72 ms 8620 KB Output is correct
59 Correct 71 ms 8472 KB Output is correct
60 Correct 77 ms 8512 KB Output is correct
61 Correct 90 ms 8544 KB Output is correct
62 Correct 76 ms 8408 KB Output is correct
63 Correct 66 ms 8260 KB Output is correct
64 Correct 71 ms 8368 KB Output is correct
65 Correct 70 ms 8360 KB Output is correct
66 Correct 71 ms 8360 KB Output is correct
67 Correct 73 ms 8592 KB Output is correct
68 Correct 90 ms 8708 KB Output is correct
69 Correct 89 ms 8568 KB Output is correct
70 Correct 82 ms 8516 KB Output is correct
71 Correct 2 ms 2636 KB Output is correct
72 Correct 3 ms 2764 KB Output is correct
73 Correct 3 ms 2764 KB Output is correct
74 Correct 3 ms 2764 KB Output is correct
75 Correct 3 ms 2764 KB Output is correct
76 Correct 3 ms 2764 KB Output is correct
77 Correct 3 ms 2764 KB Output is correct
78 Correct 4 ms 2764 KB Output is correct
79 Correct 3 ms 2764 KB Output is correct
80 Correct 87 ms 8632 KB Output is correct
81 Correct 78 ms 8536 KB Output is correct
82 Correct 108 ms 8516 KB Output is correct
83 Correct 77 ms 8516 KB Output is correct
84 Correct 5 ms 2812 KB Output is correct
85 Correct 5 ms 2804 KB Output is correct
86 Correct 3 ms 2764 KB Output is correct
87 Correct 3 ms 2764 KB Output is correct
88 Correct 4 ms 2764 KB Output is correct
89 Correct 4 ms 2764 KB Output is correct
90 Correct 3 ms 2764 KB Output is correct
91 Correct 3 ms 2764 KB Output is correct
92 Correct 3 ms 2828 KB Output is correct
93 Correct 4 ms 2764 KB Output is correct
94 Correct 2 ms 2636 KB Output is correct
95 Correct 2 ms 2636 KB Output is correct
96 Correct 2 ms 2636 KB Output is correct
97 Correct 2 ms 2636 KB Output is correct
98 Correct 2 ms 2636 KB Output is correct
99 Correct 2 ms 2680 KB Output is correct
100 Correct 2 ms 2636 KB Output is correct
101 Correct 2 ms 2636 KB Output is correct
102 Correct 2 ms 2636 KB Output is correct
103 Correct 2 ms 2636 KB Output is correct
104 Correct 7 ms 3380 KB Output is correct
105 Correct 14 ms 4876 KB Output is correct
106 Correct 2 ms 2636 KB Output is correct
107 Correct 29 ms 5964 KB Output is correct
108 Correct 36 ms 7620 KB Output is correct
109 Correct 3 ms 2636 KB Output is correct
110 Correct 58 ms 9136 KB Output is correct
111 Correct 72 ms 9396 KB Output is correct
112 Correct 3 ms 2636 KB Output is correct
113 Correct 110 ms 13980 KB Output is correct
114 Correct 50 ms 8772 KB Output is correct
115 Incorrect 52 ms 8732 KB Output isn't correct
116 Halted 0 ms 0 KB -