#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++;
}
return path1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
2 ms |
336 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
336 KB |
Output is correct |
2 |
Correct |
7 ms |
336 KB |
Output is correct |
3 |
Correct |
8 ms |
336 KB |
Output is correct |
4 |
Correct |
7 ms |
336 KB |
Output is correct |
5 |
Correct |
7 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
336 KB |
Output is correct |
2 |
Correct |
9 ms |
336 KB |
Output is correct |
3 |
Correct |
7 ms |
336 KB |
Output is correct |
4 |
Correct |
8 ms |
336 KB |
Output is correct |
5 |
Correct |
7 ms |
336 KB |
Output is correct |
6 |
Incorrect |
1 ms |
336 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
336 KB |
Output is correct |
2 |
Correct |
8 ms |
504 KB |
Output is correct |
3 |
Correct |
7 ms |
336 KB |
Output is correct |
4 |
Correct |
8 ms |
336 KB |
Output is correct |
5 |
Correct |
8 ms |
336 KB |
Output is correct |
6 |
Correct |
10 ms |
336 KB |
Output is correct |
7 |
Correct |
7 ms |
336 KB |
Output is correct |
8 |
Correct |
9 ms |
336 KB |
Output is correct |
9 |
Correct |
7 ms |
336 KB |
Output is correct |
10 |
Correct |
7 ms |
336 KB |
Output is correct |
11 |
Correct |
8 ms |
336 KB |
Output is correct |
12 |
Correct |
6 ms |
336 KB |
Output is correct |
13 |
Correct |
7 ms |
336 KB |
Output is correct |
14 |
Correct |
11 ms |
336 KB |
Output is correct |
15 |
Correct |
9 ms |
336 KB |
Output is correct |
16 |
Incorrect |
1 ms |
336 KB |
Incorrect |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
336 KB |
Output is correct |
2 |
Correct |
6 ms |
336 KB |
Output is correct |
3 |
Correct |
7 ms |
336 KB |
Output is correct |
4 |
Correct |
7 ms |
336 KB |
Output is correct |
5 |
Correct |
8 ms |
336 KB |
Output is correct |
6 |
Incorrect |
1 ms |
336 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |