#include <vector>
#include <set>
#include "longesttrip.h"
using namespace std;
int const MAXN=256;
set<int>nei[MAXN]={};
vector<int>ans;
vector<int>cur;
bool vis[MAXN]={};
void dfs(int u,int p=-1)
{
vis[u]=1;
cur.push_back(u);
if (cur.size()>ans.size())
ans=cur;
for (auto i:nei[u])
{
if (vis[i])
continue;
dfs(i,u);
}
cur.pop_back();
}
vector<int> longest_trip(int N, int D)
{
ans={};
cur={};
for (int i=0;i<N;i++)
nei[i]={};
for (int i=0;i<N;i++)
for (int j=i+1;j<N;j++)
if (are_connected({i},{j}))
nei[i].insert(j),nei[j].insert(i);
for (int i=0;i<N;i++)
{
for (int j=0;j<N;j++)
vis[j]=0;
dfs(i);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
353 ms |
3260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
344 KB |
Output is correct |
2 |
Correct |
25 ms |
344 KB |
Output is correct |
3 |
Correct |
146 ms |
344 KB |
Output is correct |
4 |
Correct |
604 ms |
1016 KB |
Output is correct |
5 |
Execution timed out |
1965 ms |
3444 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
26 ms |
400 KB |
Output is correct |
3 |
Correct |
171 ms |
520 KB |
Output is correct |
4 |
Correct |
648 ms |
1216 KB |
Output is correct |
5 |
Execution timed out |
2037 ms |
3792 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
28 ms |
344 KB |
Output is correct |
3 |
Correct |
157 ms |
344 KB |
Output is correct |
4 |
Correct |
648 ms |
1136 KB |
Output is correct |
5 |
Execution timed out |
2016 ms |
3608 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
344 KB |
Output is correct |
2 |
Correct |
23 ms |
344 KB |
Output is correct |
3 |
Partially correct |
173 ms |
344 KB |
Output is partially correct |
4 |
Partially correct |
710 ms |
1104 KB |
Output is partially correct |
5 |
Execution timed out |
2007 ms |
3428 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |