Submission #741593

# Submission time Handle Problem Language Result Execution time Memory
741593 2023-05-14T12:41:38 Z MODDI Dreaming (IOI13_dreaming) C++14
Compilation error
0 ms 0 KB
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,long long> > G[100100];
bool vis[100100];
long long distance[100100][2];
int center = -1, path = -1;
set<pair<int,long long> > c;
pair<int, long long > dfs(int at, long long dist, int id){
	pair<int, long long> rez = make_pair(at, dist);
	distance[at][id] = dist;
	if(path != -1){
		if(distance[at][0] + dist == path){
			c.insert(make_pair(at, max(distance[at][0], dist)));
		}
	}
	for(auto next : G[at]){
		if(!vis[next.first]){
			pair<int, long long> cur = dfs(next.first, dist + next.second, id);
			if(cur.second > rez.second){
				rez = cur;
			}
		}
	}
	return rez;
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    memset(vis, false, sizeof vis);
    for(int i = 0; i < M; i++){
    	G[A[i]].pb(mp(B[i], T[i]));
    	G[B[i]].pb(mp(A[i], T[i]));
	}
	vector<pair<int, long long> > arr;
    for(int i = 0; i < N; i++){
    	if(vis[i])	continue;
    	else{
    		c.clear();
    		pair<int, long long> a = dfs(0, 0);
    		pair<int, long long> b = dfs(a.first, 0); // a i b kraevi na diameter
    		path = b.second;
    		pair<int, long long> s = dfs(a.first, 0);
    		arr.pb(*c.begin());
		}
	}
	sort(arr.rbegin(), arr.rend());
	int ans = arr[0].second + arr[1].second + L;
	return ans;
}

Compilation message

dreaming.cpp: In function 'std::pair<int, long long int> dfs(int, long long int, int)':
dreaming.cpp:11:2: error: reference to 'distance' is ambiguous
   11 |  distance[at][id] = dist;
      |  ^~~~~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from dreaming.cpp:2:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:138:5: note: candidates are: 'template<class _InputIterator> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator)'
  138 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~
dreaming.cpp:6:11: note:                 'long long int distance [100100][2]'
    6 | long long distance[100100][2];
      |           ^~~~~~~~
dreaming.cpp:13:6: error: reference to 'distance' is ambiguous
   13 |   if(distance[at][0] + dist == path){
      |      ^~~~~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from dreaming.cpp:2:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:138:5: note: candidates are: 'template<class _InputIterator> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator)'
  138 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~
dreaming.cpp:6:11: note:                 'long long int distance [100100][2]'
    6 | long long distance[100100][2];
      |           ^~~~~~~~
dreaming.cpp:14:31: error: reference to 'distance' is ambiguous
   14 |    c.insert(make_pair(at, max(distance[at][0], dist)));
      |                               ^~~~~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from dreaming.cpp:2:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:138:5: note: candidates are: 'template<class _InputIterator> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator)'
  138 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~
dreaming.cpp:6:11: note:                 'long long int distance [100100][2]'
    6 | long long distance[100100][2];
      |           ^~~~~~~~
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:30:14: error: 'class std::vector<std::pair<int, long long int> >' has no member named 'pb'
   30 |      G[A[i]].pb(mp(B[i], T[i]));
      |              ^~
dreaming.cpp:30:17: error: 'mp' was not declared in this scope
   30 |      G[A[i]].pb(mp(B[i], T[i]));
      |                 ^~
dreaming.cpp:31:14: error: 'class std::vector<std::pair<int, long long int> >' has no member named 'pb'
   31 |      G[B[i]].pb(mp(A[i], T[i]));
      |              ^~
dreaming.cpp:38:40: error: too few arguments to function 'std::pair<int, long long int> dfs(int, long long int, int)'
   38 |       pair<int, long long> a = dfs(0, 0);
      |                                        ^
dreaming.cpp:9:23: note: declared here
    9 | pair<int, long long > dfs(int at, long long dist, int id){
      |                       ^~~
dreaming.cpp:39:46: error: too few arguments to function 'std::pair<int, long long int> dfs(int, long long int, int)'
   39 |       pair<int, long long> b = dfs(a.first, 0); // a i b kraevi na diameter
      |                                              ^
dreaming.cpp:9:23: note: declared here
    9 | pair<int, long long > dfs(int at, long long dist, int id){
      |                       ^~~
dreaming.cpp:41:46: error: too few arguments to function 'std::pair<int, long long int> dfs(int, long long int, int)'
   41 |       pair<int, long long> s = dfs(a.first, 0);
      |                                              ^
dreaming.cpp:9:23: note: declared here
    9 | pair<int, long long > dfs(int at, long long dist, int id){
      |                       ^~~
dreaming.cpp:42:11: error: 'class std::vector<std::pair<int, long long int> >' has no member named 'pb'
   42 |       arr.pb(*c.begin());
      |           ^~
dreaming.cpp:41:28: warning: unused variable 's' [-Wunused-variable]
   41 |       pair<int, long long> s = dfs(a.first, 0);
      |                            ^