#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;
std::vector<int> longest_trip(int n, int d)
{
vector<pair<int,int>> disc;
for (int i = 0; i < n-1; i++) {
for (int j = i+1; j < n; j++)
{
if(!are_connected({i}, {j})){
disc.push_back({i,j});
break;
}
}
}
vector<bool> rem(n);
vector<int> path(disc.size()*2);
int mid=disc.size();
for (int i = 0; i < (int)disc.size(); i++)
{
path[i]=disc[i].first;
path[i+mid]=disc[i].second;
rem[disc[i].first]=true;
rem[disc[i].second]=true;
}
for (int i = 0; i < n; i++) {
if(!rem[i]) path.push_back(i);
}
return path;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
23 ms |
344 KB |
Output is correct |
3 |
Correct |
121 ms |
344 KB |
Output is correct |
4 |
Correct |
394 ms |
344 KB |
Output is correct |
5 |
Correct |
756 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
344 KB |
Output is correct |
2 |
Correct |
21 ms |
344 KB |
Output is correct |
3 |
Correct |
129 ms |
344 KB |
Output is correct |
4 |
Correct |
384 ms |
344 KB |
Output is correct |
5 |
Correct |
742 ms |
408 KB |
Output is correct |
6 |
Incorrect |
0 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
23 ms |
344 KB |
Output is correct |
3 |
Correct |
132 ms |
344 KB |
Output is correct |
4 |
Correct |
338 ms |
340 KB |
Output is correct |
5 |
Correct |
747 ms |
408 KB |
Output is correct |
6 |
Incorrect |
0 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
344 KB |
Output is correct |
2 |
Correct |
23 ms |
344 KB |
Output is correct |
3 |
Partially correct |
132 ms |
344 KB |
Output is partially correct |
4 |
Partially correct |
361 ms |
344 KB |
Output is partially correct |
5 |
Partially correct |
769 ms |
416 KB |
Output is partially correct |
6 |
Incorrect |
0 ms |
596 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |