Submission #31786

# Submission time Handle Problem Language Result Execution time Memory
31786 2017-09-09T03:30:25 Z Diuven Dreaming (IOI13_dreaming) C++11
Compilation error
0 ms 0 KB
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
typedef struct {int to, cost;} edge;
vector<edge> G[100010], T(100010);
vector<int> rad;
bool done[100010];
int N, M, L, tmp, sz[100010], u, D;
int find(int v, bool trace=false, int p=-1, int d=0){
	done[v]=true;
	if(tmp<d)	tmp=d, u=v;
	int mx=0;
	for(auto& e:G[v]){
		if(e.to==p)	continue;
		int down=find(e.to, false, v, d+e.cost)+e.cost;
		if(down>mx)	mx=down, T[v]=e;
	}
	return mx;
}
int findcen(int v){
	tmp=-1, find(v); int a=u;
	tmp=-1, T.clear(), find(a,true); int b=u, dia=tmp, now=0;
	while(a!=b){
		int nxt=now+T[a].cost;
		if(nxt<=dia-nxt){
			a=T[a].to, now=nxt;	continue;
		}
		if(max(now, dia-now)>max(nxt, dia-nxt))
			a=T[a].to;
		break;
	}
	return a;
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]){
	for(int i=1; i<=M; i++){
		G[A[i]+1].push_back({B[i]+1, c});
		G[B[i]+1].push_back({A[i]+1, c});
	}
	for(int i=1; i<=N; i++)
		if(!done[i]){
			int c=findcen(i);
			tmp=-1, find(c), rad.push_back(tmp);
			tmp=-1, find(u), D=max(D, tmp);
		}
	sort(rad.begin(), rad.end(), greater<int>());
	if(rad.size()>1U)	D=max(D, rad[0]+rad[1]+L);
	if(rad.size()>2U)	D=max(D, rad[1]+rad[2]+2*L);
	return D;
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:36:32: error: 'c' was not declared in this scope
   G[A[i]+1].push_back({B[i]+1, c});
                                ^
dreaming.cpp:36:34: error: no matching function for call to 'std::vector<edge>::push_back(<brace-enclosed initializer list>)'
   G[A[i]+1].push_back({B[i]+1, c});
                                  ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from dreaming.cpp:2:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = edge; _Alloc = std::allocator<edge>; std::vector<_Tp, _Alloc>::value_type = edge]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const edge&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = edge; _Alloc = std::allocator<edge>; std::vector<_Tp, _Alloc>::value_type = edge]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<edge>::value_type&& {aka edge&&}'
dreaming.cpp:37:34: error: no matching function for call to 'std::vector<edge>::push_back(<brace-enclosed initializer list>)'
   G[B[i]+1].push_back({A[i]+1, c});
                                  ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from dreaming.cpp:2:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = edge; _Alloc = std::allocator<edge>; std::vector<_Tp, _Alloc>::value_type = edge]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const edge&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = edge; _Alloc = std::allocator<edge>; std::vector<_Tp, _Alloc>::value_type = edge]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<edge>::value_type&& {aka edge&&}'