#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
const int N = 256, T = 1e1, T2 = 1e2;
mt19937 rng(time(nullptr) + (uint64_t) new char);
int a[1], b[1], cnt, cnt2;
vector<int> adj[N], ans, curr;
bitset<N> con[N], vis;
void dfs(int u) {
if (curr.size() > ans.size()) ans = curr;
cnt++;
cnt2++;
if (cnt > T) return;
for (int& v : adj[u]) {
if (vis[v]) continue;
vis[v] = 1;
curr.push_back(v);
dfs(v);
if (cnt > T) return;
curr.pop_back();
vis[v] = 0;
}
}
vector<int> longest_trip(int N, int D)
{
if (D == 3) {
ans.resize(N);
for (int i = 0; i < N; i++) ans[i] = i;
return ans;
}
else {
for (int i = 0; i < N; i++) {
for (int j = i+1; j < N; j++) {
a[0] = i;
b[0] = j;
if (are_connected({i}, {j})) {
adj[i].push_back(j);
adj[j].push_back(i);
con[i][j] = con[j][i] = 1;
}
}
}
cnt = cnt2 = 0;
while (cnt2 < T2) {
cnt = 0;
dfs(rng() % N);
}
return ans;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
600 KB |
Output is correct |
2 |
Incorrect |
22 ms |
1368 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
856 KB |
Output is correct |
2 |
Incorrect |
22 ms |
864 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
856 KB |
Output is correct |
2 |
Incorrect |
27 ms |
616 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |