Submission #995797

# Submission time Handle Problem Language Result Execution time Memory
995797 2024-06-09T23:26:49 Z aaaaaarroz Longest Trip (IOI23_longesttrip) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
bool are_connected(vector<int> A, vector<int> B);
vector<int> longest_trip(int N, int D){
	vector<vector<int>>graph(N);
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(are_connected({i}.{j})){
				graph[i].push_back(j);
				graph[j].push_back(i);
			}
		}
	}
	int max_dist=0;
	vector<int>ans;
	for(int i=0;i<N;i++){
		vector<int>dist(N,-1);
		vectoor<int>parent(N,-1);
		dist[i]=0;
		queue<int>cola;
		cola.push(i);
		while(!cola.empty()){
			int nodo=cola.front();
			cola.pop();
			for(int vecino:graph[nodo]){
				if(dist[vecino]==-1){
					parent[vecino]=nodo;
					dist[vecino]=(dist[nodo]+1);
					cola.push(nodo);
				}
			}
		}
		if(*max_element(dist.begin(),dist.end())>max_dist){
			max_dist=*max_element(dist.begin(),dist.end())>max_dist;
			vector<int>path;
			int best_node=max_element(dist.begin(),dist.end())-dist.begin();
			while(parent[best_node]!=-1){
				path.push_back(best_node);
				best_node=parent[best_node];
			}
			path.push_back(best_node);
			ans=path;
		}
	}
    return ans;
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:8:24: error: expected ')' before '.' token
    8 |    if(are_connected({i}.{j})){
      |                    ~   ^
      |                        )
longesttrip.cpp:8:28: error: too few arguments to function 'bool are_connected(std::vector<int>, std::vector<int>)'
    8 |    if(are_connected({i}.{j})){
      |                            ^
longesttrip.cpp:3:6: note: declared here
    3 | bool are_connected(vector<int> A, vector<int> B);
      |      ^~~~~~~~~~~~~
longesttrip.cpp:18:3: error: 'vectoor' was not declared in this scope
   18 |   vectoor<int>parent(N,-1);
      |   ^~~~~~~
longesttrip.cpp:18:11: error: expected primary-expression before 'int'
   18 |   vectoor<int>parent(N,-1);
      |           ^~~
longesttrip.cpp:27:6: error: 'parent' was not declared in this scope
   27 |      parent[vecino]=nodo;
      |      ^~~~~~
longesttrip.cpp:37:10: error: 'parent' was not declared in this scope
   37 |    while(parent[best_node]!=-1){
      |          ^~~~~~