#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;
typedef long long ll;
vector<vector<ll>> adj;
vector<bool> vst;
mt19937 mt;
vector<int> mxRand() {
ll n = adj.size();
ll start = mt() % n;
ll cur = start;
vector<int> res = {(int)start};
loop:
vst[cur] = true;
shuffle(adj[cur].begin(), adj[cur].end(), mt);
for (auto &e : adj[cur]) {
if (!vst[e]) {
cur = e;
res.push_back(e);
goto loop;
}
}
for (auto &e : res) vst[e] = false;
return res;
}
vector<int> longest_trip(int n, int d) {
mt = mt19937(time(0));
adj = vector<vector<ll>>(n);
vst = vector<bool>(n);
for (int i = 0; i < n; i++) {
for (int j = i+1; j < n; j++) {
if (are_connected({i}, {j})) {
adj[i].push_back(j);
adj[j].push_back(i);
}
}
}
vector<int> res;
for (int i = 0; i < 256; i++) {
vector<int> nw = mxRand();
if (nw.size() > res.size()) res = nw;
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
250 ms |
1048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
344 KB |
Output is correct |
2 |
Correct |
43 ms |
344 KB |
Output is correct |
3 |
Correct |
207 ms |
464 KB |
Output is correct |
4 |
Correct |
594 ms |
592 KB |
Output is correct |
5 |
Execution timed out |
1104 ms |
1328 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
344 KB |
Output is correct |
2 |
Correct |
33 ms |
344 KB |
Output is correct |
3 |
Correct |
217 ms |
464 KB |
Output is correct |
4 |
Correct |
643 ms |
1480 KB |
Output is correct |
5 |
Execution timed out |
1217 ms |
996 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
344 KB |
Output is correct |
2 |
Correct |
51 ms |
344 KB |
Output is correct |
3 |
Correct |
229 ms |
592 KB |
Output is correct |
4 |
Correct |
607 ms |
576 KB |
Output is correct |
5 |
Execution timed out |
1258 ms |
1148 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
344 KB |
Output is correct |
2 |
Correct |
46 ms |
344 KB |
Output is correct |
3 |
Partially correct |
215 ms |
600 KB |
Output is partially correct |
4 |
Partially correct |
588 ms |
832 KB |
Output is partially correct |
5 |
Execution timed out |
1240 ms |
1596 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |