# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1105002 | Gr1sen | Longest Trip (IOI23_longesttrip) | C++17 | 11 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "longesttrip.h"
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define vi vector<int>
#define concatenate(v1,v2) v1.insert(v1.end(), v2.begin(), v2.end());
vector<int> longest_trip(int N, int D) {
//cerr << "oink" << endl;
vi path1 = {0}, path2;
int i = 1;
while (i < N) {
//cerr << i << endl;
if (are_connected({i}, {path1.back()})) {
path1.push_back(i);
if (!path2.empty() && are_connected({i}, {path2.back()})) {
concatenate(path1, path2);
path2.clear();
}
i++;
continue;
}
path2.push_back(i);
if (path1.size() < path2.size()) swap(path1, path2);
i++;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |