Submission #939696

# Submission time Handle Problem Language Result Execution time Memory
939696 2024-03-06T16:42:38 Z weajink Longest Trip (IOI23_longesttrip) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<int> sciezka[2];

void dodaj_wierzcholek(int v){
	if (!sciezka[0].size() || are_connected({v},{sciezka[0].back()})){
		sciezka[0].push_back(v);
		return;
	}
	if (!sciezka[1].size() || are_connected({v},{sciezka[1].back()})){
		sciezka[1].push_back(v);
		return;
	}
	for (int i = (int)sciezka[1].size()-1; i >= 0; i--) sciezka[0].push_back(sciezka[1][i]);
	sciezka[1] = {v};
}
vector<int> longest_trip(int N, int D){
	sciezka[0].clear();
	sciezka[1].clear();
	for (int i = 1; i <= N; i++) dodaj_wierzcholek(i);
	if (sciezka[0].size() < sciezka[1].size()) swap(sciezka[0],sciezka[1]);
	return sciezka[0];
}

Compilation message

longesttrip.cpp: In function 'void dodaj_wierzcholek(int)':
longesttrip.cpp:8:28: error: 'are_connected' was not declared in this scope
    8 |  if (!sciezka[0].size() || are_connected({v},{sciezka[0].back()})){
      |                            ^~~~~~~~~~~~~
longesttrip.cpp:12:28: error: 'are_connected' was not declared in this scope
   12 |  if (!sciezka[1].size() || are_connected({v},{sciezka[1].back()})){
      |                            ^~~~~~~~~~~~~