Submission #947383

# Submission time Handle Problem Language Result Execution time Memory
947383 2024-03-16T05:02:19 Z adkjt Dreaming (IOI13_dreaming) C++14
47 / 100
46 ms 18132 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]=1e9;
        //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]>=1e9)
                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);
}*/

# Verdict Execution time Memory Grader output
1 Correct 40 ms 17364 KB Output is correct
2 Correct 33 ms 17108 KB Output is correct
3 Correct 23 ms 14004 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 10076 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 17 ms 11092 KB Output is correct
9 Correct 21 ms 12376 KB Output is correct
10 Correct 3 ms 7772 KB Output is correct
11 Correct 35 ms 13552 KB Output is correct
12 Correct 37 ms 15444 KB Output is correct
13 Correct 2 ms 8280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7768 KB Output is correct
2 Correct 2 ms 7772 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 7768 KB Output is correct
10 Correct 2 ms 7768 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 7768 KB Output is correct
15 Correct 2 ms 7768 KB Output is correct
16 Correct 2 ms 7768 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 7768 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 7768 KB Output is correct
23 Correct 2 ms 7772 KB Output is correct
24 Correct 2 ms 8024 KB Output is correct
25 Correct 2 ms 7784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 17364 KB Output is correct
2 Correct 33 ms 17108 KB Output is correct
3 Correct 23 ms 14004 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 10076 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 17 ms 11092 KB Output is correct
9 Correct 21 ms 12376 KB Output is correct
10 Correct 3 ms 7772 KB Output is correct
11 Correct 35 ms 13552 KB Output is correct
12 Correct 37 ms 15444 KB Output is correct
13 Correct 2 ms 8280 KB Output is correct
14 Correct 2 ms 7768 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 2 ms 7772 KB Output is correct
21 Correct 2 ms 7772 KB Output is correct
22 Correct 2 ms 7768 KB Output is correct
23 Correct 2 ms 7768 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 7768 KB Output is correct
28 Correct 2 ms 7768 KB Output is correct
29 Correct 2 ms 7768 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 7768 KB Output is correct
33 Correct 2 ms 7772 KB Output is correct
34 Correct 2 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 8024 KB Output is correct
38 Correct 2 ms 7784 KB Output is correct
39 Correct 33 ms 17308 KB Output is correct
40 Correct 34 ms 17104 KB Output is correct
41 Correct 23 ms 14040 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 7772 KB Output is correct
46 Correct 2 ms 7772 KB Output is correct
47 Correct 2 ms 7928 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 7768 KB Output is correct
57 Correct 35 ms 11920 KB Output is correct
58 Correct 36 ms 12124 KB Output is correct
59 Correct 45 ms 12116 KB Output is correct
60 Correct 37 ms 12060 KB Output is correct
61 Correct 36 ms 11956 KB Output is correct
62 Correct 36 ms 11868 KB Output is correct
63 Correct 33 ms 11604 KB Output is correct
64 Correct 33 ms 11720 KB Output is correct
65 Correct 35 ms 11656 KB Output is correct
66 Correct 35 ms 11604 KB Output is correct
67 Correct 37 ms 11864 KB Output is correct
68 Correct 44 ms 11880 KB Output is correct
69 Correct 42 ms 12076 KB Output is correct
70 Correct 39 ms 11988 KB Output is correct
71 Correct 2 ms 7772 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 8028 KB Output is correct
76 Correct 3 ms 8028 KB Output is correct
77 Correct 3 ms 8024 KB Output is correct
78 Correct 3 ms 8028 KB Output is correct
79 Correct 3 ms 8028 KB Output is correct
80 Correct 38 ms 11856 KB Output is correct
81 Correct 37 ms 11868 KB Output is correct
82 Correct 36 ms 11972 KB Output is correct
83 Correct 36 ms 11708 KB Output is correct
84 Correct 2 ms 8024 KB Output is correct
85 Correct 2 ms 8028 KB Output is correct
86 Correct 2 ms 8028 KB Output is correct
87 Correct 2 ms 8028 KB Output is correct
88 Correct 2 ms 8028 KB Output is correct
89 Correct 3 ms 8280 KB Output is correct
90 Correct 3 ms 8028 KB Output is correct
91 Correct 3 ms 8020 KB Output is correct
92 Correct 3 ms 8028 KB Output is correct
93 Correct 3 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 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 9 ms 10076 KB Output is correct
106 Correct 2 ms 7772 KB Output is correct
107 Correct 16 ms 11132 KB Output is correct
108 Correct 22 ms 12380 KB Output is correct
109 Correct 2 ms 7772 KB Output is correct
110 Correct 29 ms 13660 KB Output is correct
111 Correct 35 ms 15548 KB Output is correct
112 Correct 2 ms 8028 KB Output is correct
113 Correct 46 ms 18132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 11744 KB Output is correct
2 Correct 16 ms 11972 KB Output is correct
3 Correct 17 ms 11868 KB Output is correct
4 Correct 16 ms 11824 KB Output is correct
5 Correct 16 ms 11844 KB Output is correct
6 Correct 17 ms 12136 KB Output is correct
7 Correct 16 ms 12124 KB Output is correct
8 Correct 15 ms 11868 KB Output is correct
9 Correct 16 ms 11868 KB Output is correct
10 Correct 16 ms 12124 KB Output is correct
11 Correct 2 ms 7772 KB Output is correct
12 Correct 7 ms 10844 KB Output is correct
13 Correct 7 ms 11100 KB Output is correct
14 Correct 8 ms 11156 KB Output is correct
15 Correct 7 ms 11096 KB Output is correct
16 Correct 8 ms 11100 KB Output is correct
17 Correct 7 ms 10844 KB Output is correct
18 Correct 7 ms 11100 KB Output is correct
19 Correct 7 ms 10888 KB Output is correct
20 Incorrect 2 ms 7772 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7768 KB Output is correct
2 Correct 2 ms 7772 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 7768 KB Output is correct
10 Correct 2 ms 7768 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 7768 KB Output is correct
15 Correct 2 ms 7768 KB Output is correct
16 Correct 2 ms 7768 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 7768 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 7768 KB Output is correct
23 Correct 2 ms 7772 KB Output is correct
24 Correct 2 ms 8024 KB Output is correct
25 Correct 2 ms 7784 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 8028 KB Output is correct
29 Correct 3 ms 7772 KB Output is correct
30 Correct 3 ms 8028 KB Output is correct
31 Correct 2 ms 8028 KB Output is correct
32 Correct 2 ms 7772 KB Output is correct
33 Correct 3 ms 8028 KB Output is correct
34 Correct 2 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 7772 KB Output is correct
39 Correct 2 ms 7772 KB Output is correct
40 Correct 2 ms 7772 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 7768 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 2 ms 7768 KB Output is correct
48 Correct 2 ms 7768 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 7768 KB Output isn't correct
53 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 40 ms 17364 KB Output is correct
2 Correct 33 ms 17108 KB Output is correct
3 Correct 23 ms 14004 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 10076 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 17 ms 11092 KB Output is correct
9 Correct 21 ms 12376 KB Output is correct
10 Correct 3 ms 7772 KB Output is correct
11 Correct 35 ms 13552 KB Output is correct
12 Correct 37 ms 15444 KB Output is correct
13 Correct 2 ms 8280 KB Output is correct
14 Correct 2 ms 7768 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 2 ms 7772 KB Output is correct
21 Correct 2 ms 7772 KB Output is correct
22 Correct 2 ms 7768 KB Output is correct
23 Correct 2 ms 7768 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 7768 KB Output is correct
28 Correct 2 ms 7768 KB Output is correct
29 Correct 2 ms 7768 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 7768 KB Output is correct
33 Correct 2 ms 7772 KB Output is correct
34 Correct 2 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 8024 KB Output is correct
38 Correct 2 ms 7784 KB Output is correct
39 Correct 33 ms 17308 KB Output is correct
40 Correct 34 ms 17104 KB Output is correct
41 Correct 23 ms 14040 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 7772 KB Output is correct
46 Correct 2 ms 7772 KB Output is correct
47 Correct 2 ms 7928 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 7768 KB Output is correct
57 Correct 35 ms 11920 KB Output is correct
58 Correct 36 ms 12124 KB Output is correct
59 Correct 45 ms 12116 KB Output is correct
60 Correct 37 ms 12060 KB Output is correct
61 Correct 36 ms 11956 KB Output is correct
62 Correct 36 ms 11868 KB Output is correct
63 Correct 33 ms 11604 KB Output is correct
64 Correct 33 ms 11720 KB Output is correct
65 Correct 35 ms 11656 KB Output is correct
66 Correct 35 ms 11604 KB Output is correct
67 Correct 37 ms 11864 KB Output is correct
68 Correct 44 ms 11880 KB Output is correct
69 Correct 42 ms 12076 KB Output is correct
70 Correct 39 ms 11988 KB Output is correct
71 Correct 2 ms 7772 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 8028 KB Output is correct
76 Correct 3 ms 8028 KB Output is correct
77 Correct 3 ms 8024 KB Output is correct
78 Correct 3 ms 8028 KB Output is correct
79 Correct 3 ms 8028 KB Output is correct
80 Correct 38 ms 11856 KB Output is correct
81 Correct 37 ms 11868 KB Output is correct
82 Correct 36 ms 11972 KB Output is correct
83 Correct 36 ms 11708 KB Output is correct
84 Correct 2 ms 8024 KB Output is correct
85 Correct 2 ms 8028 KB Output is correct
86 Correct 2 ms 8028 KB Output is correct
87 Correct 2 ms 8028 KB Output is correct
88 Correct 2 ms 8028 KB Output is correct
89 Correct 3 ms 8280 KB Output is correct
90 Correct 3 ms 8028 KB Output is correct
91 Correct 3 ms 8020 KB Output is correct
92 Correct 3 ms 8028 KB Output is correct
93 Correct 3 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 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 9 ms 10076 KB Output is correct
106 Correct 2 ms 7772 KB Output is correct
107 Correct 16 ms 11132 KB Output is correct
108 Correct 22 ms 12380 KB Output is correct
109 Correct 2 ms 7772 KB Output is correct
110 Correct 29 ms 13660 KB Output is correct
111 Correct 35 ms 15548 KB Output is correct
112 Correct 2 ms 8028 KB Output is correct
113 Correct 46 ms 18132 KB Output is correct
114 Correct 16 ms 11744 KB Output is correct
115 Correct 16 ms 11972 KB Output is correct
116 Correct 17 ms 11868 KB Output is correct
117 Correct 16 ms 11824 KB Output is correct
118 Correct 16 ms 11844 KB Output is correct
119 Correct 17 ms 12136 KB Output is correct
120 Correct 16 ms 12124 KB Output is correct
121 Correct 15 ms 11868 KB Output is correct
122 Correct 16 ms 11868 KB Output is correct
123 Correct 16 ms 12124 KB Output is correct
124 Correct 2 ms 7772 KB Output is correct
125 Correct 7 ms 10844 KB Output is correct
126 Correct 7 ms 11100 KB Output is correct
127 Correct 8 ms 11156 KB Output is correct
128 Correct 7 ms 11096 KB Output is correct
129 Correct 8 ms 11100 KB Output is correct
130 Correct 7 ms 10844 KB Output is correct
131 Correct 7 ms 11100 KB Output is correct
132 Correct 7 ms 10888 KB Output is correct
133 Incorrect 2 ms 7772 KB Output isn't correct
134 Halted 0 ms 0 KB -