#include <bits/stdc++.h>
using namespace std;
#include "longesttrip.h"
namespace {
vector<int> D3(int N, int D){
vector<int> res(N);
iota(res.begin(), res.end(), 0);
return res;
}
vector<int> D2(int N, int D){
bool edge1 = are_connected({0}, {1});
bool edge2 = are_connected({1}, {2});
bool edge3 = are_connected({2}, {0});
deque<int> res;
if (edge1 && edge2){
res.push_back(0); res.push_back(1); res.push_back(2);
}
else if (edge2 && edge3){
res.push_back(1); res.push_back(2); res.push_back(0);
}
else{
res.push_back(2); res.push_back(0); res.push_back(1);
}
for (int i = 3; i < N; i++){
bool e1 = are_connected({i}, {res.front()});
if (e1) res.push_front(i);
else res.push_back(i);
}
vector<int> vres(res.begin(), res.end());
return vres;
}
}
vector<int> longest_trip(int N, int D){
if (D == 3){
return D3(N, D);
}
if (D == 2){
return D2(N, D);
}
return {};
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
240 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
212 KB |
Output is correct |
2 |
Correct |
11 ms |
256 KB |
Output is correct |
3 |
Correct |
8 ms |
208 KB |
Output is correct |
4 |
Correct |
10 ms |
256 KB |
Output is correct |
5 |
Correct |
8 ms |
256 KB |
Output is correct |
6 |
Correct |
12 ms |
208 KB |
Output is correct |
7 |
Correct |
10 ms |
208 KB |
Output is correct |
8 |
Correct |
8 ms |
208 KB |
Output is correct |
9 |
Correct |
8 ms |
252 KB |
Output is correct |
10 |
Correct |
7 ms |
260 KB |
Output is correct |
11 |
Correct |
8 ms |
208 KB |
Output is correct |
12 |
Correct |
8 ms |
356 KB |
Output is correct |
13 |
Correct |
6 ms |
300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |