#include "bits/stdc++.h"
#include "longesttrip.h"
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //mt19937_64 for ll
int rnd(int l, int r) {
return l + rng() % (r - l + 1);
}
vector<int> longest_trip(int n, int D) {
vector<int> v = {rnd(0, n - 1)};
vector<bool> vis(n); vis[v[0]] = true;
while ((int)v.size() <= ((n + 1) >> 1)) {
bool tr = false;
for (int i = 0; i < n && !tr; i++) {
if (!vis[i] && are_connected({v.back()}, {i})) {
v.push_back(i);
tr = vis[i] = true;
}
}
if (!tr) v.pop_back();
}
return v;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Execution timed out |
3031 ms |
344 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |