답안 #947378

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
947378 2024-03-16T04:40:01 Z adkjt 꿈 (IOI13_dreaming) C++14
47 / 100
58 ms 18024 KB
#include<bits/stdc++.h>
#include "dreaming.h"
using namespace std;
#define f first
#define s second
#define pii pair<int,int>
vector<pii> g[111111];
int dis[111111],vis[111111],cendis[111111];
vector<int> diameter[111111];
int mxi=0,mxd=0,cntg=0,st,en,mxg1=-1,mxg2=-1,mxg3=-1,ans=0;
void dfs(int now,int p)
{
    vis[now]=1;
    if(dis[now]>mxd)
        mxd=dis[now],mxi=now;
    //vis[now]=1;
    for(auto x:g[now])
    {
        if(x.f==p) continue;
        dis[x.f]=dis[now]+x.s;
        dfs(x.f,now);
    }
}
bool diamake(int now,int prev,int en)
{
    diameter[cntg].push_back(now);
    if(now==en) return 1;
    for(auto x:g[now])
    {
        if(x.f==prev) continue;
        if(diamake(x.f,now,en)) return 1;
    }
    diameter[cntg].pop_back();
    return 0;
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    for(int i=0;i<M;i++)
    {
        g[A[i]].push_back({B[i],T[i]});
        g[B[i]].push_back({A[i],T[i]});
    }
    //for(int i=1;i<=N;i++) dis[i]=INT_MAX;
    for(int i=0;i<N;i++)
    {
        if(vis[i]) continue;
        cntg++;
        //vis[i]=1;
        mxi=-1,mxd=-1;
        dis[i]=0;
        dfs(i,-1);
        st=mxi;
        mxi=-1,mxd=-1;
        dis[st]=0;
        dfs(st,-1);
        en=mxi;
        ans=max(ans,mxd);
        diamake(st,-1,en);

        //disdia[cntg]=mxd;
        cendis[cntg]=INT_MAX;
        //cout<<mxd<<'\n';
        for(auto x:diameter[cntg]) cendis[cntg]=min(cendis[cntg],max(dis[x],mxd-dis[x]));
        //cout<<cendis[cntg]<<'\n';
        if(mxg1==-1||cendis[cntg]>mxg1) mxg3=mxg2,mxg2=mxg1,mxg1=cendis[cntg];
        else if(mxg2==-1||cendis[cntg]>mxg2) mxg3=mxg2,mxg2=cendis[cntg];
        else if(mxg3==-1||cendis[cntg]>mxg3) mxg3=cendis[cntg];
        //cout<<st<<' '<<en<<'\n';
    }
    //cout<<mxg1<<' '<<mxg2<<' '<<mxg3<<'\n';
    if(mxg3==-1) return max(ans,mxg1+mxg2+L);
    return max({ans,mxg1+mxg2+L,mxg2+mxg3+2*L});

}
/*int main()
{
    int n,m,l,a[111111],b[111111],t[111111];
    cin>>n>>m>>l;
    for(int i=0;i<m;i++)
        cin>>a[i]>>b[i]>>t[i];
    cout<<travelTime(n,m,l,a,b,t);
}*/

# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 17120 KB Output is correct
2 Correct 34 ms 17608 KB Output is correct
3 Correct 22 ms 14284 KB Output is correct
4 Correct 6 ms 9308 KB Output is correct
5 Correct 7 ms 8760 KB Output is correct
6 Correct 11 ms 10072 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 17 ms 10984 KB Output is correct
9 Correct 21 ms 12636 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 33 ms 13660 KB Output is correct
12 Correct 33 ms 15484 KB Output is correct
13 Correct 2 ms 8028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7772 KB Output is correct
2 Correct 2 ms 7768 KB Output is correct
3 Correct 2 ms 7772 KB Output is correct
4 Correct 2 ms 7772 KB Output is correct
5 Correct 2 ms 7772 KB Output is correct
6 Correct 2 ms 7772 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 2 ms 7772 KB Output is correct
9 Correct 2 ms 7772 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 2 ms 7772 KB Output is correct
12 Correct 2 ms 7772 KB Output is correct
13 Correct 2 ms 7772 KB Output is correct
14 Correct 2 ms 7896 KB Output is correct
15 Correct 2 ms 7772 KB Output is correct
16 Correct 2 ms 7772 KB Output is correct
17 Correct 2 ms 7772 KB Output is correct
18 Correct 2 ms 7772 KB Output is correct
19 Correct 2 ms 7772 KB Output is correct
20 Correct 3 ms 7772 KB Output is correct
21 Correct 3 ms 7772 KB Output is correct
22 Correct 2 ms 7768 KB Output is correct
23 Correct 2 ms 7772 KB Output is correct
24 Correct 2 ms 7772 KB Output is correct
25 Correct 2 ms 7800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 17120 KB Output is correct
2 Correct 34 ms 17608 KB Output is correct
3 Correct 22 ms 14284 KB Output is correct
4 Correct 6 ms 9308 KB Output is correct
5 Correct 7 ms 8760 KB Output is correct
6 Correct 11 ms 10072 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 17 ms 10984 KB Output is correct
9 Correct 21 ms 12636 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 33 ms 13660 KB Output is correct
12 Correct 33 ms 15484 KB Output is correct
13 Correct 2 ms 8028 KB Output is correct
14 Correct 2 ms 7772 KB Output is correct
15 Correct 2 ms 7768 KB Output is correct
16 Correct 2 ms 7772 KB Output is correct
17 Correct 2 ms 7772 KB Output is correct
18 Correct 2 ms 7772 KB Output is correct
19 Correct 2 ms 7772 KB Output is correct
20 Correct 2 ms 7772 KB Output is correct
21 Correct 2 ms 7772 KB Output is correct
22 Correct 2 ms 7772 KB Output is correct
23 Correct 2 ms 7772 KB Output is correct
24 Correct 2 ms 7772 KB Output is correct
25 Correct 2 ms 7772 KB Output is correct
26 Correct 2 ms 7772 KB Output is correct
27 Correct 2 ms 7896 KB Output is correct
28 Correct 2 ms 7772 KB Output is correct
29 Correct 2 ms 7772 KB Output is correct
30 Correct 2 ms 7772 KB Output is correct
31 Correct 2 ms 7772 KB Output is correct
32 Correct 2 ms 7772 KB Output is correct
33 Correct 3 ms 7772 KB Output is correct
34 Correct 3 ms 7772 KB Output is correct
35 Correct 2 ms 7768 KB Output is correct
36 Correct 2 ms 7772 KB Output is correct
37 Correct 2 ms 7772 KB Output is correct
38 Correct 2 ms 7800 KB Output is correct
39 Correct 32 ms 17376 KB Output is correct
40 Correct 35 ms 17600 KB Output is correct
41 Correct 23 ms 14424 KB Output is correct
42 Correct 6 ms 9308 KB Output is correct
43 Correct 3 ms 8024 KB Output is correct
44 Correct 2 ms 7768 KB Output is correct
45 Correct 2 ms 7772 KB Output is correct
46 Correct 2 ms 7772 KB Output is correct
47 Correct 2 ms 7772 KB Output is correct
48 Correct 2 ms 7772 KB Output is correct
49 Correct 2 ms 7772 KB Output is correct
50 Correct 3 ms 7772 KB Output is correct
51 Correct 2 ms 7772 KB Output is correct
52 Correct 2 ms 7772 KB Output is correct
53 Correct 2 ms 7772 KB Output is correct
54 Correct 2 ms 7768 KB Output is correct
55 Correct 2 ms 7860 KB Output is correct
56 Correct 2 ms 7768 KB Output is correct
57 Correct 42 ms 12508 KB Output is correct
58 Correct 41 ms 12312 KB Output is correct
59 Correct 46 ms 12372 KB Output is correct
60 Correct 42 ms 12368 KB Output is correct
61 Correct 37 ms 12112 KB Output is correct
62 Correct 38 ms 12460 KB Output is correct
63 Correct 33 ms 12040 KB Output is correct
64 Correct 34 ms 12060 KB Output is correct
65 Correct 45 ms 12112 KB Output is correct
66 Correct 35 ms 12372 KB Output is correct
67 Correct 38 ms 12368 KB Output is correct
68 Correct 58 ms 12228 KB Output is correct
69 Correct 39 ms 12340 KB Output is correct
70 Correct 42 ms 12116 KB Output is correct
71 Correct 2 ms 7768 KB Output is correct
72 Correct 3 ms 8028 KB Output is correct
73 Correct 3 ms 8028 KB Output is correct
74 Correct 3 ms 8028 KB Output is correct
75 Correct 3 ms 7968 KB Output is correct
76 Correct 3 ms 8028 KB Output is correct
77 Correct 3 ms 8028 KB Output is correct
78 Correct 3 ms 8024 KB Output is correct
79 Correct 3 ms 8028 KB Output is correct
80 Correct 38 ms 12460 KB Output is correct
81 Correct 37 ms 12380 KB Output is correct
82 Correct 37 ms 12260 KB Output is correct
83 Correct 35 ms 12068 KB Output is correct
84 Correct 3 ms 8028 KB Output is correct
85 Correct 2 ms 8028 KB Output is correct
86 Correct 4 ms 7960 KB Output is correct
87 Correct 3 ms 8028 KB Output is correct
88 Correct 3 ms 7952 KB Output is correct
89 Correct 4 ms 8028 KB Output is correct
90 Correct 3 ms 8280 KB Output is correct
91 Correct 3 ms 8028 KB Output is correct
92 Correct 3 ms 8028 KB Output is correct
93 Correct 2 ms 8028 KB Output is correct
94 Correct 2 ms 7772 KB Output is correct
95 Correct 2 ms 7772 KB Output is correct
96 Correct 2 ms 7772 KB Output is correct
97 Correct 2 ms 7772 KB Output is correct
98 Correct 2 ms 7772 KB Output is correct
99 Correct 2 ms 7772 KB Output is correct
100 Correct 2 ms 7772 KB Output is correct
101 Correct 2 ms 7768 KB Output is correct
102 Correct 2 ms 7940 KB Output is correct
103 Correct 2 ms 7772 KB Output is correct
104 Correct 5 ms 8540 KB Output is correct
105 Correct 10 ms 10076 KB Output is correct
106 Correct 2 ms 7772 KB Output is correct
107 Correct 17 ms 11124 KB Output is correct
108 Correct 23 ms 12600 KB Output is correct
109 Correct 2 ms 7772 KB Output is correct
110 Correct 31 ms 13744 KB Output is correct
111 Correct 34 ms 15588 KB Output is correct
112 Correct 2 ms 8028 KB Output is correct
113 Correct 48 ms 18024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 11868 KB Output is correct
2 Correct 18 ms 12016 KB Output is correct
3 Correct 17 ms 11864 KB Output is correct
4 Correct 17 ms 11812 KB Output is correct
5 Correct 16 ms 11864 KB Output is correct
6 Correct 18 ms 12124 KB Output is correct
7 Correct 18 ms 12124 KB Output is correct
8 Correct 16 ms 11864 KB Output is correct
9 Correct 15 ms 11868 KB Output is correct
10 Correct 17 ms 12124 KB Output is correct
11 Correct 2 ms 7772 KB Output is correct
12 Correct 7 ms 11096 KB Output is correct
13 Correct 7 ms 11100 KB Output is correct
14 Correct 8 ms 10996 KB Output is correct
15 Correct 7 ms 11352 KB Output is correct
16 Correct 9 ms 11100 KB Output is correct
17 Correct 7 ms 10844 KB Output is correct
18 Correct 7 ms 10904 KB Output is correct
19 Correct 7 ms 11100 KB Output is correct
20 Incorrect 2 ms 7776 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7772 KB Output is correct
2 Correct 2 ms 7768 KB Output is correct
3 Correct 2 ms 7772 KB Output is correct
4 Correct 2 ms 7772 KB Output is correct
5 Correct 2 ms 7772 KB Output is correct
6 Correct 2 ms 7772 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 2 ms 7772 KB Output is correct
9 Correct 2 ms 7772 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 2 ms 7772 KB Output is correct
12 Correct 2 ms 7772 KB Output is correct
13 Correct 2 ms 7772 KB Output is correct
14 Correct 2 ms 7896 KB Output is correct
15 Correct 2 ms 7772 KB Output is correct
16 Correct 2 ms 7772 KB Output is correct
17 Correct 2 ms 7772 KB Output is correct
18 Correct 2 ms 7772 KB Output is correct
19 Correct 2 ms 7772 KB Output is correct
20 Correct 3 ms 7772 KB Output is correct
21 Correct 3 ms 7772 KB Output is correct
22 Correct 2 ms 7768 KB Output is correct
23 Correct 2 ms 7772 KB Output is correct
24 Correct 2 ms 7772 KB Output is correct
25 Correct 2 ms 7800 KB Output is correct
26 Correct 2 ms 7968 KB Output is correct
27 Correct 3 ms 8028 KB Output is correct
28 Correct 3 ms 8028 KB Output is correct
29 Correct 2 ms 7772 KB Output is correct
30 Correct 3 ms 8028 KB Output is correct
31 Correct 3 ms 8032 KB Output is correct
32 Correct 2 ms 7772 KB Output is correct
33 Correct 2 ms 8028 KB Output is correct
34 Correct 3 ms 8028 KB Output is correct
35 Correct 2 ms 7772 KB Output is correct
36 Correct 2 ms 7772 KB Output is correct
37 Correct 2 ms 7772 KB Output is correct
38 Correct 2 ms 7776 KB Output is correct
39 Correct 2 ms 7772 KB Output is correct
40 Correct 2 ms 7768 KB Output is correct
41 Correct 2 ms 7772 KB Output is correct
42 Correct 2 ms 7772 KB Output is correct
43 Correct 2 ms 7772 KB Output is correct
44 Correct 2 ms 7772 KB Output is correct
45 Correct 2 ms 7948 KB Output is correct
46 Correct 2 ms 7772 KB Output is correct
47 Correct 2 ms 7772 KB Output is correct
48 Correct 2 ms 7952 KB Output is correct
49 Correct 2 ms 7772 KB Output is correct
50 Correct 2 ms 7772 KB Output is correct
51 Correct 2 ms 7768 KB Output is correct
52 Incorrect 2 ms 7772 KB Output isn't correct
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 17120 KB Output is correct
2 Correct 34 ms 17608 KB Output is correct
3 Correct 22 ms 14284 KB Output is correct
4 Correct 6 ms 9308 KB Output is correct
5 Correct 7 ms 8760 KB Output is correct
6 Correct 11 ms 10072 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 17 ms 10984 KB Output is correct
9 Correct 21 ms 12636 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 33 ms 13660 KB Output is correct
12 Correct 33 ms 15484 KB Output is correct
13 Correct 2 ms 8028 KB Output is correct
14 Correct 2 ms 7772 KB Output is correct
15 Correct 2 ms 7768 KB Output is correct
16 Correct 2 ms 7772 KB Output is correct
17 Correct 2 ms 7772 KB Output is correct
18 Correct 2 ms 7772 KB Output is correct
19 Correct 2 ms 7772 KB Output is correct
20 Correct 2 ms 7772 KB Output is correct
21 Correct 2 ms 7772 KB Output is correct
22 Correct 2 ms 7772 KB Output is correct
23 Correct 2 ms 7772 KB Output is correct
24 Correct 2 ms 7772 KB Output is correct
25 Correct 2 ms 7772 KB Output is correct
26 Correct 2 ms 7772 KB Output is correct
27 Correct 2 ms 7896 KB Output is correct
28 Correct 2 ms 7772 KB Output is correct
29 Correct 2 ms 7772 KB Output is correct
30 Correct 2 ms 7772 KB Output is correct
31 Correct 2 ms 7772 KB Output is correct
32 Correct 2 ms 7772 KB Output is correct
33 Correct 3 ms 7772 KB Output is correct
34 Correct 3 ms 7772 KB Output is correct
35 Correct 2 ms 7768 KB Output is correct
36 Correct 2 ms 7772 KB Output is correct
37 Correct 2 ms 7772 KB Output is correct
38 Correct 2 ms 7800 KB Output is correct
39 Correct 32 ms 17376 KB Output is correct
40 Correct 35 ms 17600 KB Output is correct
41 Correct 23 ms 14424 KB Output is correct
42 Correct 6 ms 9308 KB Output is correct
43 Correct 3 ms 8024 KB Output is correct
44 Correct 2 ms 7768 KB Output is correct
45 Correct 2 ms 7772 KB Output is correct
46 Correct 2 ms 7772 KB Output is correct
47 Correct 2 ms 7772 KB Output is correct
48 Correct 2 ms 7772 KB Output is correct
49 Correct 2 ms 7772 KB Output is correct
50 Correct 3 ms 7772 KB Output is correct
51 Correct 2 ms 7772 KB Output is correct
52 Correct 2 ms 7772 KB Output is correct
53 Correct 2 ms 7772 KB Output is correct
54 Correct 2 ms 7768 KB Output is correct
55 Correct 2 ms 7860 KB Output is correct
56 Correct 2 ms 7768 KB Output is correct
57 Correct 42 ms 12508 KB Output is correct
58 Correct 41 ms 12312 KB Output is correct
59 Correct 46 ms 12372 KB Output is correct
60 Correct 42 ms 12368 KB Output is correct
61 Correct 37 ms 12112 KB Output is correct
62 Correct 38 ms 12460 KB Output is correct
63 Correct 33 ms 12040 KB Output is correct
64 Correct 34 ms 12060 KB Output is correct
65 Correct 45 ms 12112 KB Output is correct
66 Correct 35 ms 12372 KB Output is correct
67 Correct 38 ms 12368 KB Output is correct
68 Correct 58 ms 12228 KB Output is correct
69 Correct 39 ms 12340 KB Output is correct
70 Correct 42 ms 12116 KB Output is correct
71 Correct 2 ms 7768 KB Output is correct
72 Correct 3 ms 8028 KB Output is correct
73 Correct 3 ms 8028 KB Output is correct
74 Correct 3 ms 8028 KB Output is correct
75 Correct 3 ms 7968 KB Output is correct
76 Correct 3 ms 8028 KB Output is correct
77 Correct 3 ms 8028 KB Output is correct
78 Correct 3 ms 8024 KB Output is correct
79 Correct 3 ms 8028 KB Output is correct
80 Correct 38 ms 12460 KB Output is correct
81 Correct 37 ms 12380 KB Output is correct
82 Correct 37 ms 12260 KB Output is correct
83 Correct 35 ms 12068 KB Output is correct
84 Correct 3 ms 8028 KB Output is correct
85 Correct 2 ms 8028 KB Output is correct
86 Correct 4 ms 7960 KB Output is correct
87 Correct 3 ms 8028 KB Output is correct
88 Correct 3 ms 7952 KB Output is correct
89 Correct 4 ms 8028 KB Output is correct
90 Correct 3 ms 8280 KB Output is correct
91 Correct 3 ms 8028 KB Output is correct
92 Correct 3 ms 8028 KB Output is correct
93 Correct 2 ms 8028 KB Output is correct
94 Correct 2 ms 7772 KB Output is correct
95 Correct 2 ms 7772 KB Output is correct
96 Correct 2 ms 7772 KB Output is correct
97 Correct 2 ms 7772 KB Output is correct
98 Correct 2 ms 7772 KB Output is correct
99 Correct 2 ms 7772 KB Output is correct
100 Correct 2 ms 7772 KB Output is correct
101 Correct 2 ms 7768 KB Output is correct
102 Correct 2 ms 7940 KB Output is correct
103 Correct 2 ms 7772 KB Output is correct
104 Correct 5 ms 8540 KB Output is correct
105 Correct 10 ms 10076 KB Output is correct
106 Correct 2 ms 7772 KB Output is correct
107 Correct 17 ms 11124 KB Output is correct
108 Correct 23 ms 12600 KB Output is correct
109 Correct 2 ms 7772 KB Output is correct
110 Correct 31 ms 13744 KB Output is correct
111 Correct 34 ms 15588 KB Output is correct
112 Correct 2 ms 8028 KB Output is correct
113 Correct 48 ms 18024 KB Output is correct
114 Correct 16 ms 11868 KB Output is correct
115 Correct 18 ms 12016 KB Output is correct
116 Correct 17 ms 11864 KB Output is correct
117 Correct 17 ms 11812 KB Output is correct
118 Correct 16 ms 11864 KB Output is correct
119 Correct 18 ms 12124 KB Output is correct
120 Correct 18 ms 12124 KB Output is correct
121 Correct 16 ms 11864 KB Output is correct
122 Correct 15 ms 11868 KB Output is correct
123 Correct 17 ms 12124 KB Output is correct
124 Correct 2 ms 7772 KB Output is correct
125 Correct 7 ms 11096 KB Output is correct
126 Correct 7 ms 11100 KB Output is correct
127 Correct 8 ms 10996 KB Output is correct
128 Correct 7 ms 11352 KB Output is correct
129 Correct 9 ms 11100 KB Output is correct
130 Correct 7 ms 10844 KB Output is correct
131 Correct 7 ms 10904 KB Output is correct
132 Correct 7 ms 11100 KB Output is correct
133 Incorrect 2 ms 7776 KB Output isn't correct
134 Halted 0 ms 0 KB -