Submission #320377

# Submission time Handle Problem Language Result Execution time Memory
320377 2020-11-08T12:19:31 Z keta_tsimakuridze Dreaming (IOI13_dreaming) C++14
47 / 100
178 ms 17636 KB
#include "dreaming.h"
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
#define MAX_N 100000

static int A[MAX_N];
static int B[MAX_N];
static int T[MAX_N];

const int N=1e5+5;
vector<pair<int,int> > V[N];
vector<int>a;
int fix[N],st[N],MxR,Mxr,mx,ans,Mx,h[N][2],R;
void dfs(int u,int p,int t){
	fix[u]=1;
	if(h[u][t]>mx) {
		mx=h[u][t]; Mx=u;
	}
	for(int i=0;i<V[u].size();i++){
		if(V[u][i].f!=p) {
			h[V[u][i].f][t]=h[u][t]+V[u][i].s;
			dfs(V[u][i].f,u,t);
		}
	}
}
void dfs1(int u,int p){
	R=min(R,max(h[u][0],h[u][1]));
	for(int i=0;i<V[u].size();i++){
		if(V[u][i].f!=p){
			dfs1(V[u][i].f,u);
		
		}
	}
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    
    for(int i=0;i<M;i++){
    	V[A[i]].push_back({B[i],T[i]});
    	V[B[i]].push_back({A[i],T[i]});
	}
	for(int i=0;i<N;i++){
		if(!fix[i]){
			
			mx=0;
			dfs(i,-1,0);
			mx=0; R=1e8;
		//	mx1=Mx;
	
		     h[Mx][0]=0;
			dfs(Mx,-1,0);//	 cout<<mx<<"_"<<R<<endl;
			ans=max(ans,mx);
			dfs(Mx,-1,1);
			dfs1(i,-1);
		a.push_back(R);
			
		}
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
//	cout<<a.size()<<" "<<a[0]<<" "<<a[1]<<endl;
	if(a.size()>=3){
		if(a[2]==a[1]) ans=max(ans,a[1]+a[2]+2*L);
	}
	else if(a.size()>=2) ans=max(ans,a[0]+a[1]+L);
	ans=max(ans,MxR+Mxr+L);
	return ans;
}/*
int main() {
	int N, M, L, i;
	int res;
	cin>>N>>M>>L;
	for (i = 0; i < M; i++)
		cin>>A[i]>>B[i]>>T[i];

	int answer = travelTime(N, M, L, A, B, T);
	printf("%d\n", answer);

	return 0;
} */

Compilation message

dreaming.cpp: In function 'void dfs(int, int, int)':
dreaming.cpp:21:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(int i=0;i<V[u].size();i++){
      |              ~^~~~~~~~~~~~
dreaming.cpp: In function 'void dfs1(int, int)':
dreaming.cpp:30:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for(int i=0;i<V[u].size();i++){
      |              ~^~~~~~~~~~~~
dreaming.cpp: At global scope:
dreaming.cpp:10:12: warning: 'T' defined but not used [-Wunused-variable]
   10 | static int T[MAX_N];
      |            ^
dreaming.cpp:9:12: warning: 'B' defined but not used [-Wunused-variable]
    9 | static int B[MAX_N];
      |            ^
dreaming.cpp:8:12: warning: 'A' defined but not used [-Wunused-variable]
    8 | static int A[MAX_N];
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 65 ms 14968 KB Output is correct
2 Correct 72 ms 14820 KB Output is correct
3 Correct 44 ms 10724 KB Output is correct
4 Correct 11 ms 4460 KB Output is correct
5 Correct 9 ms 3564 KB Output is correct
6 Correct 15 ms 5356 KB Output is correct
7 Correct 2 ms 2668 KB Output is correct
8 Correct 30 ms 6764 KB Output is correct
9 Correct 44 ms 8552 KB Output is correct
10 Correct 2 ms 2796 KB Output is correct
11 Correct 93 ms 10208 KB Output is correct
12 Correct 84 ms 12516 KB Output is correct
13 Correct 2 ms 2796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 14968 KB Output is correct
2 Correct 72 ms 14820 KB Output is correct
3 Correct 44 ms 10724 KB Output is correct
4 Correct 11 ms 4460 KB Output is correct
5 Correct 9 ms 3564 KB Output is correct
6 Correct 15 ms 5356 KB Output is correct
7 Correct 2 ms 2668 KB Output is correct
8 Correct 30 ms 6764 KB Output is correct
9 Correct 44 ms 8552 KB Output is correct
10 Correct 2 ms 2796 KB Output is correct
11 Correct 93 ms 10208 KB Output is correct
12 Correct 84 ms 12516 KB Output is correct
13 Correct 2 ms 2796 KB Output is correct
14 Correct 2 ms 2668 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
16 Correct 3 ms 2816 KB Output is correct
17 Correct 3 ms 2668 KB Output is correct
18 Correct 2 ms 2668 KB Output is correct
19 Correct 2 ms 2668 KB Output is correct
20 Correct 2 ms 2668 KB Output is correct
21 Correct 2 ms 2668 KB Output is correct
22 Correct 2 ms 2668 KB Output is correct
23 Correct 2 ms 2668 KB Output is correct
24 Correct 2 ms 2668 KB Output is correct
25 Correct 2 ms 2668 KB Output is correct
26 Correct 2 ms 2668 KB Output is correct
27 Correct 2 ms 2668 KB Output is correct
28 Correct 2 ms 2668 KB Output is correct
29 Correct 2 ms 2668 KB Output is correct
30 Correct 2 ms 2668 KB Output is correct
31 Correct 2 ms 2668 KB Output is correct
32 Correct 2 ms 2668 KB Output is correct
33 Correct 2 ms 2668 KB Output is correct
34 Correct 2 ms 2668 KB Output is correct
35 Correct 2 ms 2668 KB Output is correct
36 Correct 2 ms 2668 KB Output is correct
37 Correct 2 ms 2668 KB Output is correct
38 Correct 2 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 14968 KB Output is correct
2 Correct 72 ms 14820 KB Output is correct
3 Correct 44 ms 10724 KB Output is correct
4 Correct 11 ms 4460 KB Output is correct
5 Correct 9 ms 3564 KB Output is correct
6 Correct 15 ms 5356 KB Output is correct
7 Correct 2 ms 2668 KB Output is correct
8 Correct 30 ms 6764 KB Output is correct
9 Correct 44 ms 8552 KB Output is correct
10 Correct 2 ms 2796 KB Output is correct
11 Correct 93 ms 10208 KB Output is correct
12 Correct 84 ms 12516 KB Output is correct
13 Correct 2 ms 2796 KB Output is correct
14 Correct 2 ms 2668 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
16 Correct 3 ms 2816 KB Output is correct
17 Correct 3 ms 2668 KB Output is correct
18 Correct 2 ms 2668 KB Output is correct
19 Correct 2 ms 2668 KB Output is correct
20 Correct 2 ms 2668 KB Output is correct
21 Correct 2 ms 2668 KB Output is correct
22 Correct 2 ms 2668 KB Output is correct
23 Correct 2 ms 2668 KB Output is correct
24 Correct 2 ms 2668 KB Output is correct
25 Correct 2 ms 2668 KB Output is correct
26 Correct 2 ms 2668 KB Output is correct
27 Correct 2 ms 2668 KB Output is correct
28 Correct 2 ms 2668 KB Output is correct
29 Correct 2 ms 2668 KB Output is correct
30 Correct 2 ms 2668 KB Output is correct
31 Correct 2 ms 2668 KB Output is correct
32 Correct 2 ms 2668 KB Output is correct
33 Correct 2 ms 2668 KB Output is correct
34 Correct 2 ms 2668 KB Output is correct
35 Correct 2 ms 2668 KB Output is correct
36 Correct 2 ms 2668 KB Output is correct
37 Correct 2 ms 2668 KB Output is correct
38 Correct 2 ms 2668 KB Output is correct
39 Correct 63 ms 16100 KB Output is correct
40 Correct 71 ms 16100 KB Output is correct
41 Correct 40 ms 11620 KB Output is correct
42 Correct 9 ms 4716 KB Output is correct
43 Correct 2 ms 2668 KB Output is correct
44 Correct 2 ms 2688 KB Output is correct
45 Correct 2 ms 2668 KB Output is correct
46 Correct 2 ms 2668 KB Output is correct
47 Correct 2 ms 2668 KB Output is correct
48 Correct 2 ms 2668 KB Output is correct
49 Correct 3 ms 2800 KB Output is correct
50 Correct 2 ms 2668 KB Output is correct
51 Correct 2 ms 2668 KB Output is correct
52 Correct 2 ms 2668 KB Output is correct
53 Correct 2 ms 2668 KB Output is correct
54 Correct 2 ms 2668 KB Output is correct
55 Correct 2 ms 2796 KB Output is correct
56 Correct 2 ms 2668 KB Output is correct
57 Correct 108 ms 10468 KB Output is correct
58 Correct 139 ms 10340 KB Output is correct
59 Correct 111 ms 10340 KB Output is correct
60 Correct 105 ms 10340 KB Output is correct
61 Correct 98 ms 10468 KB Output is correct
62 Correct 117 ms 10468 KB Output is correct
63 Correct 107 ms 10084 KB Output is correct
64 Correct 111 ms 10084 KB Output is correct
65 Correct 112 ms 10340 KB Output is correct
66 Correct 119 ms 10468 KB Output is correct
67 Correct 129 ms 10468 KB Output is correct
68 Correct 103 ms 10340 KB Output is correct
69 Correct 122 ms 10724 KB Output is correct
70 Correct 131 ms 10680 KB Output is correct
71 Correct 2 ms 2668 KB Output is correct
72 Correct 4 ms 2924 KB Output is correct
73 Correct 4 ms 2924 KB Output is correct
74 Correct 4 ms 2924 KB Output is correct
75 Correct 4 ms 2924 KB Output is correct
76 Correct 3 ms 2924 KB Output is correct
77 Correct 4 ms 2924 KB Output is correct
78 Correct 4 ms 2924 KB Output is correct
79 Correct 4 ms 2924 KB Output is correct
80 Correct 102 ms 10340 KB Output is correct
81 Correct 100 ms 10340 KB Output is correct
82 Correct 107 ms 10340 KB Output is correct
83 Correct 107 ms 10468 KB Output is correct
84 Correct 3 ms 2924 KB Output is correct
85 Correct 3 ms 2796 KB Output is correct
86 Correct 3 ms 2924 KB Output is correct
87 Correct 3 ms 2924 KB Output is correct
88 Correct 3 ms 2924 KB Output is correct
89 Correct 4 ms 2924 KB Output is correct
90 Correct 4 ms 2924 KB Output is correct
91 Correct 4 ms 2924 KB Output is correct
92 Correct 3 ms 2924 KB Output is correct
93 Correct 3 ms 2924 KB Output is correct
94 Correct 2 ms 2668 KB Output is correct
95 Correct 2 ms 2668 KB Output is correct
96 Correct 2 ms 2668 KB Output is correct
97 Correct 2 ms 2668 KB Output is correct
98 Correct 2 ms 2668 KB Output is correct
99 Correct 2 ms 2668 KB Output is correct
100 Correct 2 ms 2668 KB Output is correct
101 Correct 2 ms 2668 KB Output is correct
102 Correct 2 ms 2668 KB Output is correct
103 Correct 2 ms 2668 KB Output is correct
104 Correct 10 ms 3820 KB Output is correct
105 Correct 16 ms 5612 KB Output is correct
106 Correct 2 ms 2668 KB Output is correct
107 Correct 31 ms 7272 KB Output is correct
108 Correct 38 ms 9316 KB Output is correct
109 Correct 2 ms 2796 KB Output is correct
110 Correct 79 ms 11364 KB Output is correct
111 Correct 98 ms 13668 KB Output is correct
112 Correct 3 ms 2796 KB Output is correct
113 Correct 178 ms 17636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 6504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 14968 KB Output is correct
2 Correct 72 ms 14820 KB Output is correct
3 Correct 44 ms 10724 KB Output is correct
4 Correct 11 ms 4460 KB Output is correct
5 Correct 9 ms 3564 KB Output is correct
6 Correct 15 ms 5356 KB Output is correct
7 Correct 2 ms 2668 KB Output is correct
8 Correct 30 ms 6764 KB Output is correct
9 Correct 44 ms 8552 KB Output is correct
10 Correct 2 ms 2796 KB Output is correct
11 Correct 93 ms 10208 KB Output is correct
12 Correct 84 ms 12516 KB Output is correct
13 Correct 2 ms 2796 KB Output is correct
14 Correct 2 ms 2796 KB Output is correct
15 Correct 3 ms 2796 KB Output is correct
16 Correct 3 ms 2924 KB Output is correct
17 Incorrect 2 ms 2796 KB Output isn't correct
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 14968 KB Output is correct
2 Correct 72 ms 14820 KB Output is correct
3 Correct 44 ms 10724 KB Output is correct
4 Correct 11 ms 4460 KB Output is correct
5 Correct 9 ms 3564 KB Output is correct
6 Correct 15 ms 5356 KB Output is correct
7 Correct 2 ms 2668 KB Output is correct
8 Correct 30 ms 6764 KB Output is correct
9 Correct 44 ms 8552 KB Output is correct
10 Correct 2 ms 2796 KB Output is correct
11 Correct 93 ms 10208 KB Output is correct
12 Correct 84 ms 12516 KB Output is correct
13 Correct 2 ms 2796 KB Output is correct
14 Correct 2 ms 2668 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
16 Correct 3 ms 2816 KB Output is correct
17 Correct 3 ms 2668 KB Output is correct
18 Correct 2 ms 2668 KB Output is correct
19 Correct 2 ms 2668 KB Output is correct
20 Correct 2 ms 2668 KB Output is correct
21 Correct 2 ms 2668 KB Output is correct
22 Correct 2 ms 2668 KB Output is correct
23 Correct 2 ms 2668 KB Output is correct
24 Correct 2 ms 2668 KB Output is correct
25 Correct 2 ms 2668 KB Output is correct
26 Correct 2 ms 2668 KB Output is correct
27 Correct 2 ms 2668 KB Output is correct
28 Correct 2 ms 2668 KB Output is correct
29 Correct 2 ms 2668 KB Output is correct
30 Correct 2 ms 2668 KB Output is correct
31 Correct 2 ms 2668 KB Output is correct
32 Correct 2 ms 2668 KB Output is correct
33 Correct 2 ms 2668 KB Output is correct
34 Correct 2 ms 2668 KB Output is correct
35 Correct 2 ms 2668 KB Output is correct
36 Correct 2 ms 2668 KB Output is correct
37 Correct 2 ms 2668 KB Output is correct
38 Correct 2 ms 2668 KB Output is correct
39 Correct 63 ms 16100 KB Output is correct
40 Correct 71 ms 16100 KB Output is correct
41 Correct 40 ms 11620 KB Output is correct
42 Correct 9 ms 4716 KB Output is correct
43 Correct 2 ms 2668 KB Output is correct
44 Correct 2 ms 2688 KB Output is correct
45 Correct 2 ms 2668 KB Output is correct
46 Correct 2 ms 2668 KB Output is correct
47 Correct 2 ms 2668 KB Output is correct
48 Correct 2 ms 2668 KB Output is correct
49 Correct 3 ms 2800 KB Output is correct
50 Correct 2 ms 2668 KB Output is correct
51 Correct 2 ms 2668 KB Output is correct
52 Correct 2 ms 2668 KB Output is correct
53 Correct 2 ms 2668 KB Output is correct
54 Correct 2 ms 2668 KB Output is correct
55 Correct 2 ms 2796 KB Output is correct
56 Correct 2 ms 2668 KB Output is correct
57 Correct 108 ms 10468 KB Output is correct
58 Correct 139 ms 10340 KB Output is correct
59 Correct 111 ms 10340 KB Output is correct
60 Correct 105 ms 10340 KB Output is correct
61 Correct 98 ms 10468 KB Output is correct
62 Correct 117 ms 10468 KB Output is correct
63 Correct 107 ms 10084 KB Output is correct
64 Correct 111 ms 10084 KB Output is correct
65 Correct 112 ms 10340 KB Output is correct
66 Correct 119 ms 10468 KB Output is correct
67 Correct 129 ms 10468 KB Output is correct
68 Correct 103 ms 10340 KB Output is correct
69 Correct 122 ms 10724 KB Output is correct
70 Correct 131 ms 10680 KB Output is correct
71 Correct 2 ms 2668 KB Output is correct
72 Correct 4 ms 2924 KB Output is correct
73 Correct 4 ms 2924 KB Output is correct
74 Correct 4 ms 2924 KB Output is correct
75 Correct 4 ms 2924 KB Output is correct
76 Correct 3 ms 2924 KB Output is correct
77 Correct 4 ms 2924 KB Output is correct
78 Correct 4 ms 2924 KB Output is correct
79 Correct 4 ms 2924 KB Output is correct
80 Correct 102 ms 10340 KB Output is correct
81 Correct 100 ms 10340 KB Output is correct
82 Correct 107 ms 10340 KB Output is correct
83 Correct 107 ms 10468 KB Output is correct
84 Correct 3 ms 2924 KB Output is correct
85 Correct 3 ms 2796 KB Output is correct
86 Correct 3 ms 2924 KB Output is correct
87 Correct 3 ms 2924 KB Output is correct
88 Correct 3 ms 2924 KB Output is correct
89 Correct 4 ms 2924 KB Output is correct
90 Correct 4 ms 2924 KB Output is correct
91 Correct 4 ms 2924 KB Output is correct
92 Correct 3 ms 2924 KB Output is correct
93 Correct 3 ms 2924 KB Output is correct
94 Correct 2 ms 2668 KB Output is correct
95 Correct 2 ms 2668 KB Output is correct
96 Correct 2 ms 2668 KB Output is correct
97 Correct 2 ms 2668 KB Output is correct
98 Correct 2 ms 2668 KB Output is correct
99 Correct 2 ms 2668 KB Output is correct
100 Correct 2 ms 2668 KB Output is correct
101 Correct 2 ms 2668 KB Output is correct
102 Correct 2 ms 2668 KB Output is correct
103 Correct 2 ms 2668 KB Output is correct
104 Correct 10 ms 3820 KB Output is correct
105 Correct 16 ms 5612 KB Output is correct
106 Correct 2 ms 2668 KB Output is correct
107 Correct 31 ms 7272 KB Output is correct
108 Correct 38 ms 9316 KB Output is correct
109 Correct 2 ms 2796 KB Output is correct
110 Correct 79 ms 11364 KB Output is correct
111 Correct 98 ms 13668 KB Output is correct
112 Correct 3 ms 2796 KB Output is correct
113 Correct 178 ms 17636 KB Output is correct
114 Incorrect 28 ms 6504 KB Output isn't correct
115 Halted 0 ms 0 KB -