Submission #1069659

# Submission time Handle Problem Language Result Execution time Memory
1069659 2024-08-22T07:50:42 Z Muhammad_Aneeq Longest Trip (IOI23_longesttrip) C++17
Compilation error
0 ms 0 KB
#include <vector>
#include <set>
using namespace std;
int const MAXN=256;
set<int>nei[MAXN]={};
vector<int>ans;
vector<int>cur;
bool vis[MAXN]={};
void dfs(int u,int p=-1)
{
	vis[u]=1;
	cur.push_back(u);
	if (cur.size()>ans.size())
		ans=cur;
	for (auto i:nei[u])
	{
		if (vis[i])
			continue;
		dfs(i,u);
	}
	cur.pop_back();
}
vector<int> longest_trip(int N, int D)
{
	ans={};
	cur={};
	for (int i=0;i<N;i++)
		nei[i]={};
	for (int i=0;i<N;i++)
		for (int j=i+1;j<N;j++)
			if (are_connected({i},{j}))
				nei[i].insert(j),nei[j].insert(i);
	for (int i=0;i<N;i++)
	{
		for (int j=0;j<N;j++)
			vis[j]=0;
		dfs(i);
	}
	return ans;
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:31:8: error: 'are_connected' was not declared in this scope
   31 |    if (are_connected({i},{j}))
      |        ^~~~~~~~~~~~~