답안 #947380

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
947380 2024-03-16T04:54:01 Z adkjt 꿈 (IOI13_dreaming) C++14
47 / 100
47 ms 18220 KB
#include<bits/stdc++.h>
#include "dreaming.h"
using namespace std;
#define f first
#define s second
#define pii pair<int,int>
#define ll long long
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(cendis[cntg]>=INT_MAX) cendis[cntg]=0;
        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 37 ms 17624 KB Output is correct
2 Correct 34 ms 17628 KB Output is correct
3 Correct 23 ms 14288 KB Output is correct
4 Correct 6 ms 9308 KB Output is correct
5 Correct 6 ms 8540 KB Output is correct
6 Correct 10 ms 10096 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 17 ms 11136 KB Output is correct
9 Correct 21 ms 12628 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 30 ms 13560 KB Output is correct
12 Correct 34 ms 15576 KB Output is correct
13 Correct 2 ms 8024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7768 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 7768 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 7768 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 7772 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 7768 KB Output is correct
18 Correct 2 ms 7948 KB Output is correct
19 Correct 2 ms 7772 KB Output is correct
20 Correct 2 ms 7772 KB Output is correct
21 Correct 3 ms 7772 KB Output is correct
22 Correct 2 ms 7772 KB Output is correct
23 Correct 3 ms 7772 KB Output is correct
24 Correct 2 ms 7772 KB Output is correct
25 Correct 2 ms 7772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 17624 KB Output is correct
2 Correct 34 ms 17628 KB Output is correct
3 Correct 23 ms 14288 KB Output is correct
4 Correct 6 ms 9308 KB Output is correct
5 Correct 6 ms 8540 KB Output is correct
6 Correct 10 ms 10096 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 17 ms 11136 KB Output is correct
9 Correct 21 ms 12628 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 30 ms 13560 KB Output is correct
12 Correct 34 ms 15576 KB Output is correct
13 Correct 2 ms 8024 KB Output is correct
14 Correct 2 ms 7768 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 7768 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 7768 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 7772 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 7768 KB Output is correct
31 Correct 2 ms 7948 KB Output is correct
32 Correct 2 ms 7772 KB Output is correct
33 Correct 2 ms 7772 KB Output is correct
34 Correct 3 ms 7772 KB Output is correct
35 Correct 2 ms 7772 KB Output is correct
36 Correct 3 ms 7772 KB Output is correct
37 Correct 2 ms 7772 KB Output is correct
38 Correct 2 ms 7772 KB Output is correct
39 Correct 34 ms 17576 KB Output is correct
40 Correct 35 ms 17576 KB Output is correct
41 Correct 26 ms 14428 KB Output is correct
42 Correct 6 ms 9308 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 7768 KB Output is correct
46 Correct 2 ms 7768 KB Output is correct
47 Correct 2 ms 7768 KB Output is correct
48 Correct 2 ms 7772 KB Output is correct
49 Correct 2 ms 7948 KB Output is correct
50 Correct 2 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 7772 KB Output is correct
55 Correct 2 ms 7772 KB Output is correct
56 Correct 2 ms 7772 KB Output is correct
57 Correct 35 ms 12532 KB Output is correct
58 Correct 40 ms 12380 KB Output is correct
59 Correct 38 ms 12376 KB Output is correct
60 Correct 38 ms 12380 KB Output is correct
61 Correct 37 ms 12340 KB Output is correct
62 Correct 40 ms 12112 KB Output is correct
63 Correct 34 ms 12116 KB Output is correct
64 Correct 33 ms 12056 KB Output is correct
65 Correct 36 ms 12060 KB Output is correct
66 Correct 36 ms 12120 KB Output is correct
67 Correct 39 ms 12292 KB Output is correct
68 Correct 39 ms 12208 KB Output is correct
69 Correct 40 ms 12380 KB Output is correct
70 Correct 41 ms 12352 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 8024 KB Output is correct
75 Correct 3 ms 8024 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 8028 KB Output is correct
79 Correct 2 ms 8028 KB Output is correct
80 Correct 39 ms 12436 KB Output is correct
81 Correct 39 ms 12400 KB Output is correct
82 Correct 36 ms 12124 KB Output is correct
83 Correct 36 ms 12076 KB Output is correct
84 Correct 3 ms 8028 KB Output is correct
85 Correct 2 ms 8028 KB Output is correct
86 Correct 3 ms 8028 KB Output is correct
87 Correct 3 ms 8024 KB Output is correct
88 Correct 3 ms 8028 KB Output is correct
89 Correct 3 ms 8028 KB Output is correct
90 Correct 3 ms 8028 KB Output is correct
91 Correct 3 ms 8028 KB Output is correct
92 Correct 2 ms 8028 KB Output is correct
93 Correct 3 ms 8020 KB Output is correct
94 Correct 2 ms 7768 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 7768 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 7772 KB Output is correct
102 Correct 2 ms 7772 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 9980 KB Output is correct
106 Correct 2 ms 7772 KB Output is correct
107 Correct 17 ms 11084 KB Output is correct
108 Correct 27 ms 12636 KB Output is correct
109 Correct 2 ms 7772 KB Output is correct
110 Correct 32 ms 13744 KB Output is correct
111 Correct 34 ms 15576 KB Output is correct
112 Correct 2 ms 8028 KB Output is correct
113 Correct 47 ms 18220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 11868 KB Output is correct
2 Correct 18 ms 11868 KB Output is correct
3 Correct 16 ms 11864 KB Output is correct
4 Correct 16 ms 11868 KB Output is correct
5 Correct 15 ms 11856 KB Output is correct
6 Correct 17 ms 12124 KB Output is correct
7 Correct 16 ms 12120 KB Output is correct
8 Correct 15 ms 12120 KB Output is correct
9 Correct 15 ms 11864 KB Output is correct
10 Correct 16 ms 12120 KB Output is correct
11 Correct 2 ms 7772 KB Output is correct
12 Correct 7 ms 10844 KB Output is correct
13 Correct 8 ms 11100 KB Output is correct
14 Correct 7 ms 10920 KB Output is correct
15 Correct 7 ms 10844 KB Output is correct
16 Correct 7 ms 10844 KB Output is correct
17 Correct 7 ms 11024 KB Output is correct
18 Correct 7 ms 11044 KB Output is correct
19 Correct 8 ms 11264 KB Output is correct
20 Incorrect 2 ms 7772 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7768 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 7768 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 7768 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 7772 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 7768 KB Output is correct
18 Correct 2 ms 7948 KB Output is correct
19 Correct 2 ms 7772 KB Output is correct
20 Correct 2 ms 7772 KB Output is correct
21 Correct 3 ms 7772 KB Output is correct
22 Correct 2 ms 7772 KB Output is correct
23 Correct 3 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 8028 KB Output is correct
28 Correct 3 ms 8280 KB Output is correct
29 Correct 2 ms 7772 KB Output is correct
30 Correct 3 ms 8024 KB Output is correct
31 Correct 3 ms 8280 KB Output is correct
32 Correct 2 ms 7768 KB Output is correct
33 Correct 2 ms 8024 KB Output is correct
34 Correct 2 ms 8028 KB Output is correct
35 Correct 2 ms 7768 KB Output is correct
36 Correct 2 ms 7904 KB Output is correct
37 Correct 2 ms 7772 KB Output is correct
38 Correct 2 ms 7972 KB Output is correct
39 Correct 2 ms 7768 KB Output is correct
40 Correct 2 ms 7960 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 7772 KB Output is correct
46 Correct 2 ms 7772 KB Output is correct
47 Correct 3 ms 7924 KB Output is correct
48 Correct 2 ms 7772 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 7772 KB Output is correct
52 Incorrect 2 ms 7772 KB Output isn't correct
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 17624 KB Output is correct
2 Correct 34 ms 17628 KB Output is correct
3 Correct 23 ms 14288 KB Output is correct
4 Correct 6 ms 9308 KB Output is correct
5 Correct 6 ms 8540 KB Output is correct
6 Correct 10 ms 10096 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 17 ms 11136 KB Output is correct
9 Correct 21 ms 12628 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 30 ms 13560 KB Output is correct
12 Correct 34 ms 15576 KB Output is correct
13 Correct 2 ms 8024 KB Output is correct
14 Correct 2 ms 7768 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 7768 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 7768 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 7772 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 7768 KB Output is correct
31 Correct 2 ms 7948 KB Output is correct
32 Correct 2 ms 7772 KB Output is correct
33 Correct 2 ms 7772 KB Output is correct
34 Correct 3 ms 7772 KB Output is correct
35 Correct 2 ms 7772 KB Output is correct
36 Correct 3 ms 7772 KB Output is correct
37 Correct 2 ms 7772 KB Output is correct
38 Correct 2 ms 7772 KB Output is correct
39 Correct 34 ms 17576 KB Output is correct
40 Correct 35 ms 17576 KB Output is correct
41 Correct 26 ms 14428 KB Output is correct
42 Correct 6 ms 9308 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 7768 KB Output is correct
46 Correct 2 ms 7768 KB Output is correct
47 Correct 2 ms 7768 KB Output is correct
48 Correct 2 ms 7772 KB Output is correct
49 Correct 2 ms 7948 KB Output is correct
50 Correct 2 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 7772 KB Output is correct
55 Correct 2 ms 7772 KB Output is correct
56 Correct 2 ms 7772 KB Output is correct
57 Correct 35 ms 12532 KB Output is correct
58 Correct 40 ms 12380 KB Output is correct
59 Correct 38 ms 12376 KB Output is correct
60 Correct 38 ms 12380 KB Output is correct
61 Correct 37 ms 12340 KB Output is correct
62 Correct 40 ms 12112 KB Output is correct
63 Correct 34 ms 12116 KB Output is correct
64 Correct 33 ms 12056 KB Output is correct
65 Correct 36 ms 12060 KB Output is correct
66 Correct 36 ms 12120 KB Output is correct
67 Correct 39 ms 12292 KB Output is correct
68 Correct 39 ms 12208 KB Output is correct
69 Correct 40 ms 12380 KB Output is correct
70 Correct 41 ms 12352 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 8024 KB Output is correct
75 Correct 3 ms 8024 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 8028 KB Output is correct
79 Correct 2 ms 8028 KB Output is correct
80 Correct 39 ms 12436 KB Output is correct
81 Correct 39 ms 12400 KB Output is correct
82 Correct 36 ms 12124 KB Output is correct
83 Correct 36 ms 12076 KB Output is correct
84 Correct 3 ms 8028 KB Output is correct
85 Correct 2 ms 8028 KB Output is correct
86 Correct 3 ms 8028 KB Output is correct
87 Correct 3 ms 8024 KB Output is correct
88 Correct 3 ms 8028 KB Output is correct
89 Correct 3 ms 8028 KB Output is correct
90 Correct 3 ms 8028 KB Output is correct
91 Correct 3 ms 8028 KB Output is correct
92 Correct 2 ms 8028 KB Output is correct
93 Correct 3 ms 8020 KB Output is correct
94 Correct 2 ms 7768 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 7768 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 7772 KB Output is correct
102 Correct 2 ms 7772 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 9980 KB Output is correct
106 Correct 2 ms 7772 KB Output is correct
107 Correct 17 ms 11084 KB Output is correct
108 Correct 27 ms 12636 KB Output is correct
109 Correct 2 ms 7772 KB Output is correct
110 Correct 32 ms 13744 KB Output is correct
111 Correct 34 ms 15576 KB Output is correct
112 Correct 2 ms 8028 KB Output is correct
113 Correct 47 ms 18220 KB Output is correct
114 Correct 18 ms 11868 KB Output is correct
115 Correct 18 ms 11868 KB Output is correct
116 Correct 16 ms 11864 KB Output is correct
117 Correct 16 ms 11868 KB Output is correct
118 Correct 15 ms 11856 KB Output is correct
119 Correct 17 ms 12124 KB Output is correct
120 Correct 16 ms 12120 KB Output is correct
121 Correct 15 ms 12120 KB Output is correct
122 Correct 15 ms 11864 KB Output is correct
123 Correct 16 ms 12120 KB Output is correct
124 Correct 2 ms 7772 KB Output is correct
125 Correct 7 ms 10844 KB Output is correct
126 Correct 8 ms 11100 KB Output is correct
127 Correct 7 ms 10920 KB Output is correct
128 Correct 7 ms 10844 KB Output is correct
129 Correct 7 ms 10844 KB Output is correct
130 Correct 7 ms 11024 KB Output is correct
131 Correct 7 ms 11044 KB Output is correct
132 Correct 8 ms 11264 KB Output is correct
133 Incorrect 2 ms 7772 KB Output isn't correct
134 Halted 0 ms 0 KB -