Submission #76624

# Submission time Handle Problem Language Result Execution time Memory
76624 2018-09-15T09:00:36 Z Bodo171 Dreaming (IOI13_dreaming) C++14
47 / 100
119 ms 11640 KB
#include "dreaming.h"
#include <iostream>
#include <vector>
using namespace std;
const int nmax=100005;
vector< pair<int,int> > v[nmax];
vector<int> centr;
int d[nmax],viz[nmax],rep[nmax],dist[nmax];
int far,root,n,nr,i,x,mx,mn,ans,maxdiam;
void dfs(int x)
{
    int nod=0;
    viz[x]=1;rep[++nr]=x;
    for(int i=0;i<v[x].size();i++)
    {
        nod=v[x][i].first;
        if(!viz[nod])
        {
            d[nod]=d[x]+v[x][i].second;
            dfs(nod);
        }
    }
}
void get_diam()
{
    far=root;nr=0;
    dfs(root);
    for(i=1;i<=nr;i++)
    {
        x=rep[i];
        if(d[x]>d[far])
            far=x;
        viz[x]=0;
    }
    nr=0;d[far]=0;
    dfs(far);
    for(i=1;i<=nr;i++)
    {
        x=rep[i];
        if(d[x]>d[far])
            far=x;
        dist[x]=max(dist[x],d[x]);
        if(d[x]>maxdiam)
            maxdiam=d[x];
        viz[x]=0;
    }
    d[far]=0;nr=0;
    dfs(far);
    for(i=1;i<=nr;i++)
    {
        x=rep[i];
        dist[x]=max(dist[x],d[x]);
    }
    mn=(1<<30);
    for(i=1;i<=nr;i++)
    {
        x=rep[i];
        if(dist[x]<mn)
            mn=dist[x];
    }
    centr.push_back(mn);
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    n=N;
    for(i=0;i<M;i++)
    {
        v[A[i]].push_back({B[i],T[i]});
        v[B[i]].push_back({A[i],T[i]});
    }
    for(root=0;root<n;root++)
        if(!viz[root])
            get_diam();
    for(i=0;i<centr.size();i++)
    {
        ans+=centr[i];
        if(i+1<centr.size())
            ans+=L;
    }
    return max(ans,maxdiam);
}

Compilation message

dreaming.cpp: In function 'void dfs(int)':
dreaming.cpp:14:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<v[x].size();i++)
                 ~^~~~~~~~~~~~
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:73:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0;i<centr.size();i++)
             ~^~~~~~~~~~~~~
dreaming.cpp:76:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(i+1<centr.size())
            ~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 71 ms 10872 KB Output is correct
2 Correct 77 ms 10876 KB Output is correct
3 Correct 44 ms 8104 KB Output is correct
4 Correct 11 ms 3840 KB Output is correct
5 Correct 10 ms 3456 KB Output is correct
6 Correct 18 ms 4480 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 33 ms 5752 KB Output is correct
9 Correct 39 ms 6888 KB Output is correct
10 Correct 4 ms 2688 KB Output is correct
11 Correct 97 ms 8244 KB Output is correct
12 Correct 69 ms 9464 KB Output is correct
13 Correct 4 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 10872 KB Output is correct
2 Correct 77 ms 10876 KB Output is correct
3 Correct 44 ms 8104 KB Output is correct
4 Correct 11 ms 3840 KB Output is correct
5 Correct 10 ms 3456 KB Output is correct
6 Correct 18 ms 4480 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 33 ms 5752 KB Output is correct
9 Correct 39 ms 6888 KB Output is correct
10 Correct 4 ms 2688 KB Output is correct
11 Correct 97 ms 8244 KB Output is correct
12 Correct 69 ms 9464 KB Output is correct
13 Correct 4 ms 2816 KB Output is correct
14 Correct 4 ms 2688 KB Output is correct
15 Correct 4 ms 2688 KB Output is correct
16 Correct 4 ms 2688 KB Output is correct
17 Correct 4 ms 2688 KB Output is correct
18 Correct 4 ms 2688 KB Output is correct
19 Correct 4 ms 2688 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 4 ms 2688 KB Output is correct
22 Correct 4 ms 2688 KB Output is correct
23 Correct 4 ms 2688 KB Output is correct
24 Correct 4 ms 2688 KB Output is correct
25 Correct 4 ms 2688 KB Output is correct
26 Correct 4 ms 2688 KB Output is correct
27 Correct 3 ms 2688 KB Output is correct
28 Correct 3 ms 2688 KB Output is correct
29 Correct 4 ms 2688 KB Output is correct
30 Correct 4 ms 2688 KB Output is correct
31 Correct 4 ms 2688 KB Output is correct
32 Correct 4 ms 2692 KB Output is correct
33 Correct 4 ms 2688 KB Output is correct
34 Correct 4 ms 2688 KB Output is correct
35 Correct 3 ms 2688 KB Output is correct
36 Correct 4 ms 2688 KB Output is correct
37 Correct 4 ms 2688 KB Output is correct
38 Correct 4 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 10872 KB Output is correct
2 Correct 77 ms 10876 KB Output is correct
3 Correct 44 ms 8104 KB Output is correct
4 Correct 11 ms 3840 KB Output is correct
5 Correct 10 ms 3456 KB Output is correct
6 Correct 18 ms 4480 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 33 ms 5752 KB Output is correct
9 Correct 39 ms 6888 KB Output is correct
10 Correct 4 ms 2688 KB Output is correct
11 Correct 97 ms 8244 KB Output is correct
12 Correct 69 ms 9464 KB Output is correct
13 Correct 4 ms 2816 KB Output is correct
14 Correct 4 ms 2688 KB Output is correct
15 Correct 4 ms 2688 KB Output is correct
16 Correct 4 ms 2688 KB Output is correct
17 Correct 4 ms 2688 KB Output is correct
18 Correct 4 ms 2688 KB Output is correct
19 Correct 4 ms 2688 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 4 ms 2688 KB Output is correct
22 Correct 4 ms 2688 KB Output is correct
23 Correct 4 ms 2688 KB Output is correct
24 Correct 4 ms 2688 KB Output is correct
25 Correct 4 ms 2688 KB Output is correct
26 Correct 4 ms 2688 KB Output is correct
27 Correct 3 ms 2688 KB Output is correct
28 Correct 3 ms 2688 KB Output is correct
29 Correct 4 ms 2688 KB Output is correct
30 Correct 4 ms 2688 KB Output is correct
31 Correct 4 ms 2688 KB Output is correct
32 Correct 4 ms 2692 KB Output is correct
33 Correct 4 ms 2688 KB Output is correct
34 Correct 4 ms 2688 KB Output is correct
35 Correct 3 ms 2688 KB Output is correct
36 Correct 4 ms 2688 KB Output is correct
37 Correct 4 ms 2688 KB Output is correct
38 Correct 4 ms 2688 KB Output is correct
39 Correct 80 ms 10988 KB Output is correct
40 Correct 67 ms 10864 KB Output is correct
41 Correct 46 ms 8056 KB Output is correct
42 Correct 11 ms 3968 KB Output is correct
43 Correct 4 ms 2688 KB Output is correct
44 Correct 4 ms 2688 KB Output is correct
45 Correct 3 ms 2688 KB Output is correct
46 Correct 4 ms 2688 KB Output is correct
47 Correct 4 ms 2688 KB Output is correct
48 Correct 4 ms 2688 KB Output is correct
49 Correct 4 ms 2688 KB Output is correct
50 Correct 3 ms 2688 KB Output is correct
51 Correct 4 ms 2688 KB Output is correct
52 Correct 4 ms 2688 KB Output is correct
53 Correct 4 ms 2688 KB Output is correct
54 Correct 3 ms 2688 KB Output is correct
55 Correct 4 ms 2688 KB Output is correct
56 Correct 4 ms 2688 KB Output is correct
57 Correct 114 ms 9404 KB Output is correct
58 Correct 93 ms 9332 KB Output is correct
59 Correct 101 ms 9236 KB Output is correct
60 Correct 118 ms 9024 KB Output is correct
61 Correct 81 ms 9336 KB Output is correct
62 Correct 77 ms 9080 KB Output is correct
63 Correct 86 ms 9208 KB Output is correct
64 Correct 74 ms 9080 KB Output is correct
65 Correct 81 ms 9088 KB Output is correct
66 Correct 80 ms 9080 KB Output is correct
67 Correct 119 ms 9208 KB Output is correct
68 Correct 87 ms 9208 KB Output is correct
69 Correct 114 ms 9080 KB Output is correct
70 Correct 101 ms 9080 KB Output is correct
71 Correct 3 ms 2688 KB Output is correct
72 Correct 6 ms 2944 KB Output is correct
73 Correct 5 ms 2944 KB Output is correct
74 Correct 5 ms 2944 KB Output is correct
75 Correct 5 ms 2944 KB Output is correct
76 Correct 5 ms 2944 KB Output is correct
77 Correct 6 ms 2944 KB Output is correct
78 Correct 5 ms 2944 KB Output is correct
79 Correct 6 ms 2944 KB Output is correct
80 Correct 105 ms 9208 KB Output is correct
81 Correct 104 ms 9208 KB Output is correct
82 Correct 111 ms 9212 KB Output is correct
83 Correct 89 ms 9188 KB Output is correct
84 Correct 5 ms 2944 KB Output is correct
85 Correct 5 ms 2816 KB Output is correct
86 Correct 5 ms 2944 KB Output is correct
87 Correct 5 ms 2816 KB Output is correct
88 Correct 5 ms 2916 KB Output is correct
89 Correct 5 ms 2944 KB Output is correct
90 Correct 5 ms 2944 KB Output is correct
91 Correct 5 ms 2944 KB Output is correct
92 Correct 5 ms 2944 KB Output is correct
93 Correct 5 ms 2944 KB Output is correct
94 Correct 4 ms 2688 KB Output is correct
95 Correct 4 ms 2688 KB Output is correct
96 Correct 4 ms 2688 KB Output is correct
97 Correct 4 ms 2688 KB Output is correct
98 Correct 4 ms 2688 KB Output is correct
99 Correct 4 ms 2688 KB Output is correct
100 Correct 4 ms 2688 KB Output is correct
101 Correct 4 ms 2688 KB Output is correct
102 Correct 4 ms 2688 KB Output is correct
103 Correct 4 ms 2688 KB Output is correct
104 Correct 11 ms 3456 KB Output is correct
105 Correct 20 ms 4480 KB Output is correct
106 Correct 4 ms 2688 KB Output is correct
107 Correct 31 ms 5752 KB Output is correct
108 Correct 41 ms 6904 KB Output is correct
109 Correct 4 ms 2688 KB Output is correct
110 Correct 62 ms 8156 KB Output is correct
111 Correct 72 ms 9432 KB Output is correct
112 Correct 4 ms 2816 KB Output is correct
113 Correct 105 ms 11640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 6528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 10872 KB Output is correct
2 Correct 77 ms 10876 KB Output is correct
3 Correct 44 ms 8104 KB Output is correct
4 Correct 11 ms 3840 KB Output is correct
5 Correct 10 ms 3456 KB Output is correct
6 Correct 18 ms 4480 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 33 ms 5752 KB Output is correct
9 Correct 39 ms 6888 KB Output is correct
10 Correct 4 ms 2688 KB Output is correct
11 Correct 97 ms 8244 KB Output is correct
12 Correct 69 ms 9464 KB Output is correct
13 Correct 4 ms 2816 KB Output is correct
14 Incorrect 4 ms 2688 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 10872 KB Output is correct
2 Correct 77 ms 10876 KB Output is correct
3 Correct 44 ms 8104 KB Output is correct
4 Correct 11 ms 3840 KB Output is correct
5 Correct 10 ms 3456 KB Output is correct
6 Correct 18 ms 4480 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 33 ms 5752 KB Output is correct
9 Correct 39 ms 6888 KB Output is correct
10 Correct 4 ms 2688 KB Output is correct
11 Correct 97 ms 8244 KB Output is correct
12 Correct 69 ms 9464 KB Output is correct
13 Correct 4 ms 2816 KB Output is correct
14 Correct 4 ms 2688 KB Output is correct
15 Correct 4 ms 2688 KB Output is correct
16 Correct 4 ms 2688 KB Output is correct
17 Correct 4 ms 2688 KB Output is correct
18 Correct 4 ms 2688 KB Output is correct
19 Correct 4 ms 2688 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 4 ms 2688 KB Output is correct
22 Correct 4 ms 2688 KB Output is correct
23 Correct 4 ms 2688 KB Output is correct
24 Correct 4 ms 2688 KB Output is correct
25 Correct 4 ms 2688 KB Output is correct
26 Correct 4 ms 2688 KB Output is correct
27 Correct 3 ms 2688 KB Output is correct
28 Correct 3 ms 2688 KB Output is correct
29 Correct 4 ms 2688 KB Output is correct
30 Correct 4 ms 2688 KB Output is correct
31 Correct 4 ms 2688 KB Output is correct
32 Correct 4 ms 2692 KB Output is correct
33 Correct 4 ms 2688 KB Output is correct
34 Correct 4 ms 2688 KB Output is correct
35 Correct 3 ms 2688 KB Output is correct
36 Correct 4 ms 2688 KB Output is correct
37 Correct 4 ms 2688 KB Output is correct
38 Correct 4 ms 2688 KB Output is correct
39 Correct 80 ms 10988 KB Output is correct
40 Correct 67 ms 10864 KB Output is correct
41 Correct 46 ms 8056 KB Output is correct
42 Correct 11 ms 3968 KB Output is correct
43 Correct 4 ms 2688 KB Output is correct
44 Correct 4 ms 2688 KB Output is correct
45 Correct 3 ms 2688 KB Output is correct
46 Correct 4 ms 2688 KB Output is correct
47 Correct 4 ms 2688 KB Output is correct
48 Correct 4 ms 2688 KB Output is correct
49 Correct 4 ms 2688 KB Output is correct
50 Correct 3 ms 2688 KB Output is correct
51 Correct 4 ms 2688 KB Output is correct
52 Correct 4 ms 2688 KB Output is correct
53 Correct 4 ms 2688 KB Output is correct
54 Correct 3 ms 2688 KB Output is correct
55 Correct 4 ms 2688 KB Output is correct
56 Correct 4 ms 2688 KB Output is correct
57 Correct 114 ms 9404 KB Output is correct
58 Correct 93 ms 9332 KB Output is correct
59 Correct 101 ms 9236 KB Output is correct
60 Correct 118 ms 9024 KB Output is correct
61 Correct 81 ms 9336 KB Output is correct
62 Correct 77 ms 9080 KB Output is correct
63 Correct 86 ms 9208 KB Output is correct
64 Correct 74 ms 9080 KB Output is correct
65 Correct 81 ms 9088 KB Output is correct
66 Correct 80 ms 9080 KB Output is correct
67 Correct 119 ms 9208 KB Output is correct
68 Correct 87 ms 9208 KB Output is correct
69 Correct 114 ms 9080 KB Output is correct
70 Correct 101 ms 9080 KB Output is correct
71 Correct 3 ms 2688 KB Output is correct
72 Correct 6 ms 2944 KB Output is correct
73 Correct 5 ms 2944 KB Output is correct
74 Correct 5 ms 2944 KB Output is correct
75 Correct 5 ms 2944 KB Output is correct
76 Correct 5 ms 2944 KB Output is correct
77 Correct 6 ms 2944 KB Output is correct
78 Correct 5 ms 2944 KB Output is correct
79 Correct 6 ms 2944 KB Output is correct
80 Correct 105 ms 9208 KB Output is correct
81 Correct 104 ms 9208 KB Output is correct
82 Correct 111 ms 9212 KB Output is correct
83 Correct 89 ms 9188 KB Output is correct
84 Correct 5 ms 2944 KB Output is correct
85 Correct 5 ms 2816 KB Output is correct
86 Correct 5 ms 2944 KB Output is correct
87 Correct 5 ms 2816 KB Output is correct
88 Correct 5 ms 2916 KB Output is correct
89 Correct 5 ms 2944 KB Output is correct
90 Correct 5 ms 2944 KB Output is correct
91 Correct 5 ms 2944 KB Output is correct
92 Correct 5 ms 2944 KB Output is correct
93 Correct 5 ms 2944 KB Output is correct
94 Correct 4 ms 2688 KB Output is correct
95 Correct 4 ms 2688 KB Output is correct
96 Correct 4 ms 2688 KB Output is correct
97 Correct 4 ms 2688 KB Output is correct
98 Correct 4 ms 2688 KB Output is correct
99 Correct 4 ms 2688 KB Output is correct
100 Correct 4 ms 2688 KB Output is correct
101 Correct 4 ms 2688 KB Output is correct
102 Correct 4 ms 2688 KB Output is correct
103 Correct 4 ms 2688 KB Output is correct
104 Correct 11 ms 3456 KB Output is correct
105 Correct 20 ms 4480 KB Output is correct
106 Correct 4 ms 2688 KB Output is correct
107 Correct 31 ms 5752 KB Output is correct
108 Correct 41 ms 6904 KB Output is correct
109 Correct 4 ms 2688 KB Output is correct
110 Correct 62 ms 8156 KB Output is correct
111 Correct 72 ms 9432 KB Output is correct
112 Correct 4 ms 2816 KB Output is correct
113 Correct 105 ms 11640 KB Output is correct
114 Incorrect 28 ms 6528 KB Output isn't correct
115 Halted 0 ms 0 KB -