#include "longesttrip.h"
#define sz(v) (int) v.size()
#define ff first
#define ss second
using namespace std;
typedef pair<int,int> ii;
vector<int> longest_trip(int N, int D)
{
vector<ii> ed;
vector<bool> d(N);
for(int i = 0; i < N; ++i){
for(int j = i+1; j < N; ++j){
if(!are_connected({i},{j})){
ed.push_back({i,j});
d[i] = 1, d[j] = 1;
}
}
}
vector<int> ans;
if(ed.empty()){
for(int i = 0; i < N; ++i) ans.push_back(i);
return ans;
}
if(sz(ed) == 1){
if(N == 2)
return {0};
ans.push_back(ed[0].ff);
for(int i = 0; i < N; ++i) if(!d[i]) ans.push_back(i);
ans.push_back(ed[0].ss);
return ans;
}
for(int i = 0; i < sz(ed); ++i){
ans.push_back(ed[i].ff);
}
for(int i = 0; i < sz(ed); ++i){
ans.push_back(ed[i].ss);
}
for(int i = 0; i < N; ++i) if(!d[i]) ans.push_back(i);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
208 KB |
Output is correct |
2 |
Correct |
32 ms |
208 KB |
Output is correct |
3 |
Correct |
110 ms |
208 KB |
Output is correct |
4 |
Correct |
494 ms |
208 KB |
Output is correct |
5 |
Correct |
920 ms |
268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
208 KB |
Output is correct |
2 |
Correct |
30 ms |
208 KB |
Output is correct |
3 |
Correct |
131 ms |
208 KB |
Output is correct |
4 |
Correct |
419 ms |
208 KB |
Output is correct |
5 |
Correct |
793 ms |
276 KB |
Output is correct |
6 |
Correct |
10 ms |
208 KB |
Output is correct |
7 |
Correct |
39 ms |
208 KB |
Output is correct |
8 |
Correct |
184 ms |
208 KB |
Output is correct |
9 |
Correct |
339 ms |
208 KB |
Output is correct |
10 |
Correct |
908 ms |
268 KB |
Output is correct |
11 |
Correct |
910 ms |
268 KB |
Output is correct |
12 |
Correct |
964 ms |
268 KB |
Output is correct |
13 |
Correct |
944 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
208 KB |
Output is correct |
2 |
Correct |
41 ms |
208 KB |
Output is correct |
3 |
Correct |
172 ms |
208 KB |
Output is correct |
4 |
Correct |
458 ms |
208 KB |
Output is correct |
5 |
Correct |
834 ms |
268 KB |
Output is correct |
6 |
Correct |
9 ms |
208 KB |
Output is correct |
7 |
Correct |
28 ms |
208 KB |
Output is correct |
8 |
Correct |
165 ms |
208 KB |
Output is correct |
9 |
Correct |
320 ms |
208 KB |
Output is correct |
10 |
Correct |
972 ms |
208 KB |
Output is correct |
11 |
Correct |
915 ms |
208 KB |
Output is correct |
12 |
Correct |
962 ms |
268 KB |
Output is correct |
13 |
Correct |
835 ms |
272 KB |
Output is correct |
14 |
Incorrect |
0 ms |
208 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
208 KB |
Output is correct |
2 |
Correct |
33 ms |
208 KB |
Output is correct |
3 |
Partially correct |
203 ms |
208 KB |
Output is partially correct |
4 |
Partially correct |
498 ms |
208 KB |
Output is partially correct |
5 |
Partially correct |
791 ms |
328 KB |
Output is partially correct |
6 |
Correct |
12 ms |
208 KB |
Output is correct |
7 |
Correct |
41 ms |
208 KB |
Output is correct |
8 |
Partially correct |
187 ms |
208 KB |
Output is partially correct |
9 |
Partially correct |
395 ms |
208 KB |
Output is partially correct |
10 |
Partially correct |
754 ms |
208 KB |
Output is partially correct |
11 |
Partially correct |
946 ms |
264 KB |
Output is partially correct |
12 |
Partially correct |
938 ms |
208 KB |
Output is partially correct |
13 |
Partially correct |
794 ms |
264 KB |
Output is partially correct |
14 |
Incorrect |
0 ms |
208 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |