#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);
}
if(disc.size()==1) swap(path[1],path[2]);
return path;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
344 KB |
Output is correct |
2 |
Correct |
21 ms |
344 KB |
Output is correct |
3 |
Correct |
114 ms |
344 KB |
Output is correct |
4 |
Correct |
338 ms |
344 KB |
Output is correct |
5 |
Correct |
696 ms |
408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
344 KB |
Output is correct |
2 |
Correct |
26 ms |
344 KB |
Output is correct |
3 |
Correct |
127 ms |
344 KB |
Output is correct |
4 |
Correct |
391 ms |
344 KB |
Output is correct |
5 |
Correct |
729 ms |
424 KB |
Output is correct |
6 |
Correct |
9 ms |
344 KB |
Output is correct |
7 |
Correct |
19 ms |
344 KB |
Output is correct |
8 |
Correct |
84 ms |
344 KB |
Output is correct |
9 |
Correct |
193 ms |
592 KB |
Output is correct |
10 |
Correct |
534 ms |
412 KB |
Output is correct |
11 |
Correct |
480 ms |
592 KB |
Output is correct |
12 |
Correct |
496 ms |
424 KB |
Output is correct |
13 |
Correct |
511 ms |
408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
21 ms |
344 KB |
Output is correct |
3 |
Correct |
128 ms |
344 KB |
Output is correct |
4 |
Correct |
371 ms |
344 KB |
Output is correct |
5 |
Correct |
793 ms |
412 KB |
Output is correct |
6 |
Correct |
6 ms |
344 KB |
Output is correct |
7 |
Correct |
16 ms |
344 KB |
Output is correct |
8 |
Correct |
69 ms |
344 KB |
Output is correct |
9 |
Correct |
174 ms |
600 KB |
Output is correct |
10 |
Correct |
547 ms |
500 KB |
Output is correct |
11 |
Correct |
482 ms |
416 KB |
Output is correct |
12 |
Correct |
496 ms |
592 KB |
Output is correct |
13 |
Correct |
483 ms |
408 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 |
22 ms |
344 KB |
Output is correct |
3 |
Partially correct |
122 ms |
344 KB |
Output is partially correct |
4 |
Partially correct |
377 ms |
344 KB |
Output is partially correct |
5 |
Partially correct |
737 ms |
408 KB |
Output is partially correct |
6 |
Correct |
8 ms |
344 KB |
Output is correct |
7 |
Correct |
20 ms |
596 KB |
Output is correct |
8 |
Partially correct |
81 ms |
340 KB |
Output is partially correct |
9 |
Partially correct |
185 ms |
412 KB |
Output is partially correct |
10 |
Partially correct |
549 ms |
408 KB |
Output is partially correct |
11 |
Partially correct |
525 ms |
412 KB |
Output is partially correct |
12 |
Partially correct |
490 ms |
408 KB |
Output is partially correct |
13 |
Partially correct |
490 ms |
596 KB |
Output is partially correct |
14 |
Incorrect |
0 ms |
344 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |