#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> longest_trip(int N, int D)
{
queue<int> stops;
for (int i = 1; i < N; i++) stops.push(i);
deque<int> trip = {0};
while (stops.size() > 1) {
int next = stops.front(); stops.pop();
int last = trip.back();
if (are_connected({next}, {last})) {
trip.push_back(next);
} else {
trip.push_back(stops.front()); stops.pop();
trip.push_back(next);
}
}
if (stops.size() == 1) {
int next = stops.front();
int last = trip.back();
if (are_connected({next}, {last})) {
trip.push_back(next);
} else {
trip.push_front(stops.front()); stops.pop();
}
}
vector<int> res;
for (int x : trip) res.push_back(x);
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
344 KB |
Output is correct |
2 |
Correct |
7 ms |
344 KB |
Output is correct |
3 |
Correct |
5 ms |
344 KB |
Output is correct |
4 |
Correct |
6 ms |
840 KB |
Output is correct |
5 |
Correct |
5 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
344 KB |
Output is correct |
2 |
Correct |
8 ms |
344 KB |
Output is correct |
3 |
Correct |
6 ms |
344 KB |
Output is correct |
4 |
Correct |
8 ms |
344 KB |
Output is correct |
5 |
Correct |
7 ms |
344 KB |
Output is correct |
6 |
Correct |
6 ms |
344 KB |
Output is correct |
7 |
Correct |
5 ms |
344 KB |
Output is correct |
8 |
Correct |
8 ms |
504 KB |
Output is correct |
9 |
Correct |
3 ms |
344 KB |
Output is correct |
10 |
Correct |
8 ms |
344 KB |
Output is correct |
11 |
Correct |
8 ms |
344 KB |
Output is correct |
12 |
Correct |
8 ms |
344 KB |
Output is correct |
13 |
Correct |
7 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
344 KB |
Output is correct |
2 |
Correct |
8 ms |
344 KB |
Output is correct |
3 |
Correct |
7 ms |
344 KB |
Output is correct |
4 |
Correct |
6 ms |
344 KB |
Output is correct |
5 |
Correct |
4 ms |
344 KB |
Output is correct |
6 |
Correct |
5 ms |
344 KB |
Output is correct |
7 |
Correct |
5 ms |
344 KB |
Output is correct |
8 |
Correct |
7 ms |
344 KB |
Output is correct |
9 |
Correct |
8 ms |
344 KB |
Output is correct |
10 |
Correct |
5 ms |
344 KB |
Output is correct |
11 |
Correct |
7 ms |
344 KB |
Output is correct |
12 |
Correct |
4 ms |
344 KB |
Output is correct |
13 |
Correct |
7 ms |
344 KB |
Output is correct |
14 |
Incorrect |
0 ms |
344 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
344 KB |
Output is correct |
3 |
Correct |
6 ms |
344 KB |
Output is correct |
4 |
Correct |
6 ms |
356 KB |
Output is correct |
5 |
Correct |
5 ms |
344 KB |
Output is correct |
6 |
Correct |
5 ms |
344 KB |
Output is correct |
7 |
Correct |
5 ms |
344 KB |
Output is correct |
8 |
Correct |
6 ms |
344 KB |
Output is correct |
9 |
Correct |
8 ms |
600 KB |
Output is correct |
10 |
Correct |
8 ms |
344 KB |
Output is correct |
11 |
Correct |
5 ms |
344 KB |
Output is correct |
12 |
Correct |
5 ms |
344 KB |
Output is correct |
13 |
Correct |
5 ms |
344 KB |
Output is correct |
14 |
Incorrect |
0 ms |
344 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |