답안 #452135

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
452135 2021-08-03T21:20:35 Z FEDIKUS 꿈 (IOI13_dreaming) C++17
47 / 100
108 ms 15612 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(1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 14276 KB Output is correct
2 Correct 69 ms 14268 KB Output is correct
3 Correct 37 ms 10440 KB Output is correct
4 Correct 11 ms 4300 KB Output is correct
5 Correct 8 ms 3532 KB Output is correct
6 Correct 15 ms 5196 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 28 ms 6496 KB Output is correct
9 Correct 37 ms 8360 KB Output is correct
10 Correct 3 ms 2636 KB Output is correct
11 Correct 73 ms 10332 KB Output is correct
12 Correct 60 ms 12100 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 3 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 2652 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 2656 KB Output is correct
13 Correct 2 ms 2652 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 2652 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 2656 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 2 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 14276 KB Output is correct
2 Correct 69 ms 14268 KB Output is correct
3 Correct 37 ms 10440 KB Output is correct
4 Correct 11 ms 4300 KB Output is correct
5 Correct 8 ms 3532 KB Output is correct
6 Correct 15 ms 5196 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 28 ms 6496 KB Output is correct
9 Correct 37 ms 8360 KB Output is correct
10 Correct 3 ms 2636 KB Output is correct
11 Correct 73 ms 10332 KB Output is correct
12 Correct 60 ms 12100 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 3 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 2652 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 2656 KB Output is correct
26 Correct 2 ms 2652 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 2652 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 2 ms 2636 KB Output is correct
35 Correct 2 ms 2636 KB Output is correct
36 Correct 2 ms 2656 KB Output is correct
37 Correct 2 ms 2636 KB Output is correct
38 Correct 2 ms 2636 KB Output is correct
39 Correct 58 ms 14216 KB Output is correct
40 Correct 58 ms 14256 KB Output is correct
41 Correct 37 ms 10444 KB Output is correct
42 Correct 9 ms 4400 KB Output is correct
43 Correct 2 ms 2636 KB Output is correct
44 Correct 2 ms 2652 KB Output is correct
45 Correct 2 ms 2636 KB Output is correct
46 Correct 2 ms 2652 KB Output is correct
47 Correct 2 ms 2656 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 3 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 2564 KB Output is correct
57 Correct 81 ms 9948 KB Output is correct
58 Correct 108 ms 9916 KB Output is correct
59 Correct 78 ms 10028 KB Output is correct
60 Correct 100 ms 9896 KB Output is correct
61 Correct 83 ms 10036 KB Output is correct
62 Correct 107 ms 9924 KB Output is correct
63 Correct 67 ms 9636 KB Output is correct
64 Correct 77 ms 9608 KB Output is correct
65 Correct 78 ms 9988 KB Output is correct
66 Correct 91 ms 10004 KB Output is correct
67 Correct 75 ms 9840 KB Output is correct
68 Correct 71 ms 9944 KB Output is correct
69 Correct 72 ms 10184 KB Output is correct
70 Correct 93 ms 10304 KB Output is correct
71 Correct 2 ms 2636 KB Output is correct
72 Correct 4 ms 2764 KB Output is correct
73 Correct 3 ms 2764 KB Output is correct
74 Correct 4 ms 2764 KB Output is correct
75 Correct 4 ms 2764 KB Output is correct
76 Correct 4 ms 2892 KB Output is correct
77 Correct 3 ms 2764 KB Output is correct
78 Correct 3 ms 2892 KB Output is correct
79 Correct 3 ms 2792 KB Output is correct
80 Correct 77 ms 9840 KB Output is correct
81 Correct 71 ms 9924 KB Output is correct
82 Correct 88 ms 10040 KB Output is correct
83 Correct 102 ms 9948 KB Output is correct
84 Correct 5 ms 2764 KB Output is correct
85 Correct 4 ms 2764 KB Output is correct
86 Correct 4 ms 2792 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 4 ms 2764 KB Output is correct
92 Correct 4 ms 2764 KB Output is correct
93 Correct 4 ms 2764 KB Output is correct
94 Correct 2 ms 2636 KB Output is correct
95 Correct 3 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 2664 KB Output is correct
99 Correct 2 ms 2636 KB Output is correct
100 Correct 2 ms 2636 KB Output is correct
101 Correct 2 ms 2656 KB Output is correct
102 Correct 2 ms 2636 KB Output is correct
103 Correct 2 ms 2636 KB Output is correct
104 Correct 10 ms 3516 KB Output is correct
105 Correct 18 ms 5196 KB Output is correct
106 Correct 2 ms 2636 KB Output is correct
107 Correct 27 ms 6476 KB Output is correct
108 Correct 43 ms 8368 KB Output is correct
109 Correct 2 ms 2636 KB Output is correct
110 Correct 61 ms 10368 KB Output is correct
111 Correct 63 ms 12056 KB Output is correct
112 Correct 2 ms 2636 KB Output is correct
113 Correct 97 ms 15612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 9156 KB Output is correct
2 Incorrect 47 ms 9180 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 3 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 2652 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 2656 KB Output is correct
13 Correct 2 ms 2652 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 2652 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 2656 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 2664 KB Output is correct
27 Correct 3 ms 2764 KB Output is correct
28 Correct 3 ms 2796 KB Output is correct
29 Incorrect 2 ms 2636 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 14276 KB Output is correct
2 Correct 69 ms 14268 KB Output is correct
3 Correct 37 ms 10440 KB Output is correct
4 Correct 11 ms 4300 KB Output is correct
5 Correct 8 ms 3532 KB Output is correct
6 Correct 15 ms 5196 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 28 ms 6496 KB Output is correct
9 Correct 37 ms 8360 KB Output is correct
10 Correct 3 ms 2636 KB Output is correct
11 Correct 73 ms 10332 KB Output is correct
12 Correct 60 ms 12100 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 3 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 2652 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 2656 KB Output is correct
26 Correct 2 ms 2652 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 2652 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 2 ms 2636 KB Output is correct
35 Correct 2 ms 2636 KB Output is correct
36 Correct 2 ms 2656 KB Output is correct
37 Correct 2 ms 2636 KB Output is correct
38 Correct 2 ms 2636 KB Output is correct
39 Correct 58 ms 14216 KB Output is correct
40 Correct 58 ms 14256 KB Output is correct
41 Correct 37 ms 10444 KB Output is correct
42 Correct 9 ms 4400 KB Output is correct
43 Correct 2 ms 2636 KB Output is correct
44 Correct 2 ms 2652 KB Output is correct
45 Correct 2 ms 2636 KB Output is correct
46 Correct 2 ms 2652 KB Output is correct
47 Correct 2 ms 2656 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 3 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 2564 KB Output is correct
57 Correct 81 ms 9948 KB Output is correct
58 Correct 108 ms 9916 KB Output is correct
59 Correct 78 ms 10028 KB Output is correct
60 Correct 100 ms 9896 KB Output is correct
61 Correct 83 ms 10036 KB Output is correct
62 Correct 107 ms 9924 KB Output is correct
63 Correct 67 ms 9636 KB Output is correct
64 Correct 77 ms 9608 KB Output is correct
65 Correct 78 ms 9988 KB Output is correct
66 Correct 91 ms 10004 KB Output is correct
67 Correct 75 ms 9840 KB Output is correct
68 Correct 71 ms 9944 KB Output is correct
69 Correct 72 ms 10184 KB Output is correct
70 Correct 93 ms 10304 KB Output is correct
71 Correct 2 ms 2636 KB Output is correct
72 Correct 4 ms 2764 KB Output is correct
73 Correct 3 ms 2764 KB Output is correct
74 Correct 4 ms 2764 KB Output is correct
75 Correct 4 ms 2764 KB Output is correct
76 Correct 4 ms 2892 KB Output is correct
77 Correct 3 ms 2764 KB Output is correct
78 Correct 3 ms 2892 KB Output is correct
79 Correct 3 ms 2792 KB Output is correct
80 Correct 77 ms 9840 KB Output is correct
81 Correct 71 ms 9924 KB Output is correct
82 Correct 88 ms 10040 KB Output is correct
83 Correct 102 ms 9948 KB Output is correct
84 Correct 5 ms 2764 KB Output is correct
85 Correct 4 ms 2764 KB Output is correct
86 Correct 4 ms 2792 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 4 ms 2764 KB Output is correct
92 Correct 4 ms 2764 KB Output is correct
93 Correct 4 ms 2764 KB Output is correct
94 Correct 2 ms 2636 KB Output is correct
95 Correct 3 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 2664 KB Output is correct
99 Correct 2 ms 2636 KB Output is correct
100 Correct 2 ms 2636 KB Output is correct
101 Correct 2 ms 2656 KB Output is correct
102 Correct 2 ms 2636 KB Output is correct
103 Correct 2 ms 2636 KB Output is correct
104 Correct 10 ms 3516 KB Output is correct
105 Correct 18 ms 5196 KB Output is correct
106 Correct 2 ms 2636 KB Output is correct
107 Correct 27 ms 6476 KB Output is correct
108 Correct 43 ms 8368 KB Output is correct
109 Correct 2 ms 2636 KB Output is correct
110 Correct 61 ms 10368 KB Output is correct
111 Correct 63 ms 12056 KB Output is correct
112 Correct 2 ms 2636 KB Output is correct
113 Correct 97 ms 15612 KB Output is correct
114 Correct 61 ms 9156 KB Output is correct
115 Incorrect 47 ms 9180 KB Output isn't correct
116 Halted 0 ms 0 KB -