#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;
using ll = long long;
int n, d;
bool adj[256][256];
vector<int> longest_trip(int N, int D) {
n = N;
d = D;
memset(adj, 0, sizeof adj);
for (int i = 0;i < n;i++) {
for (int j = i + 1;j < n;j++) {
adj[i][j] = adj[j][i] = are_connected({ i }, { j });
}
}
queue<int> q;
deque<int> ans;
ans.push_back(0);
for (int i = 1;i < n;i++) {
if (adj[0][i]) {
ans.push_back(i);
break;
}
}
for (int i = 1;i < n;i++) {
if (ans.back() != i) q.push(i);
}
while (!q.empty()) {
if (adj[ans.back()][q.front()]) {
ans.push_back(q.front());
q.pop();
}
else {
int v = ans.back();
ans.pop_back();
ans.push_back(q.front());
q.pop();
ans.push_back(v);
}
}
vector<int> Ans;
while (!ans.empty()) Ans.push_back(ans.front()), ans.pop_front();
return Ans;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
338 ms |
504 KB |
Output is correct |
5 |
Correct |
708 ms |
476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
22 ms |
344 KB |
Output is correct |
3 |
Correct |
126 ms |
344 KB |
Output is correct |
4 |
Correct |
348 ms |
472 KB |
Output is correct |
5 |
Correct |
735 ms |
472 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 |
26 ms |
344 KB |
Output is correct |
3 |
Correct |
117 ms |
344 KB |
Output is correct |
4 |
Correct |
357 ms |
596 KB |
Output is correct |
5 |
Correct |
707 ms |
472 KB |
Output is correct |
6 |
Incorrect |
0 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
344 KB |
Output is correct |
2 |
Correct |
22 ms |
344 KB |
Output is correct |
3 |
Partially correct |
133 ms |
340 KB |
Output is partially correct |
4 |
Partially correct |
341 ms |
344 KB |
Output is partially correct |
5 |
Partially correct |
771 ms |
472 KB |
Output is partially correct |
6 |
Incorrect |
0 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |