Submission #939665

# Submission time Handle Problem Language Result Execution time Memory
939665 2024-03-06T16:19:30 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 (i = 1; i <= n; i++) dodaj_wierzcholek(v);
	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()})){
      |                            ^~~~~~~~~~~~~
longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:22:7: error: 'i' was not declared in this scope
   22 |  for (i = 1; i <= n; i++) dodaj_wierzcholek(v);
      |       ^
longesttrip.cpp:22:19: error: 'n' was not declared in this scope
   22 |  for (i = 1; i <= n; i++) dodaj_wierzcholek(v);
      |                   ^
longesttrip.cpp:22:45: error: 'v' was not declared in this scope
   22 |  for (i = 1; i <= n; i++) dodaj_wierzcholek(v);
      |                                             ^