Submission #939697

# Submission time Handle Problem Language Result Execution time Memory
939697 2024-03-06T16:42:59 Z weajink Longest Trip (IOI23_longesttrip) C++17
0 / 100
0 ms 596 KB
#include <bits/stdc++.h>
#include "longesttrip.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];
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB invalid array
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 596 KB invalid array
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB invalid array
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB invalid array
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB invalid array
2 Halted 0 ms 0 KB -