#include <vector>
#include <set>
#include "longesttrip.h"
using namespace std;
int const MAXN=256;
vector<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);
bool w=0;
for (auto i:nei[u])
{
if (vis[i])
continue;
w=1;
dfs(i,u);
}
if (w==0)
{
if (cur.size()>ans.size())
ans=cur;
}
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].push_back(j),nei[j].push_back(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 |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
200 ms |
1296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
24 ms |
344 KB |
Output is correct |
3 |
Correct |
147 ms |
344 KB |
Output is correct |
4 |
Correct |
469 ms |
848 KB |
Output is correct |
5 |
Correct |
923 ms |
696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
23 ms |
344 KB |
Output is correct |
3 |
Correct |
155 ms |
344 KB |
Output is correct |
4 |
Correct |
403 ms |
480 KB |
Output is correct |
5 |
Correct |
982 ms |
1088 KB |
Output is correct |
6 |
Correct |
7 ms |
344 KB |
Output is correct |
7 |
Correct |
21 ms |
344 KB |
Output is correct |
8 |
Correct |
163 ms |
600 KB |
Output is correct |
9 |
Correct |
337 ms |
460 KB |
Output is correct |
10 |
Correct |
922 ms |
600 KB |
Output is correct |
11 |
Correct |
943 ms |
1112 KB |
Output is correct |
12 |
Correct |
937 ms |
892 KB |
Output is correct |
13 |
Correct |
902 ms |
1052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
23 ms |
344 KB |
Output is correct |
3 |
Correct |
138 ms |
344 KB |
Output is correct |
4 |
Correct |
451 ms |
592 KB |
Output is correct |
5 |
Correct |
904 ms |
988 KB |
Output is correct |
6 |
Correct |
7 ms |
344 KB |
Output is correct |
7 |
Correct |
27 ms |
344 KB |
Output is correct |
8 |
Correct |
155 ms |
344 KB |
Output is correct |
9 |
Correct |
304 ms |
960 KB |
Output is correct |
10 |
Correct |
895 ms |
600 KB |
Output is correct |
11 |
Correct |
904 ms |
1052 KB |
Output is correct |
12 |
Correct |
928 ms |
612 KB |
Output is correct |
13 |
Correct |
923 ms |
1036 KB |
Output is correct |
14 |
Correct |
7 ms |
344 KB |
Output is correct |
15 |
Correct |
11 ms |
344 KB |
Output is correct |
16 |
Correct |
40 ms |
344 KB |
Output is correct |
17 |
Correct |
82 ms |
344 KB |
Output is correct |
18 |
Correct |
148 ms |
344 KB |
Output is correct |
19 |
Correct |
267 ms |
344 KB |
Output is correct |
20 |
Correct |
330 ms |
856 KB |
Output is correct |
21 |
Correct |
878 ms |
792 KB |
Output is correct |
22 |
Correct |
922 ms |
1248 KB |
Output is correct |
23 |
Correct |
858 ms |
1000 KB |
Output is correct |
24 |
Correct |
869 ms |
1120 KB |
Output is correct |
25 |
Correct |
8 ms |
344 KB |
Output is correct |
26 |
Correct |
9 ms |
344 KB |
Output is correct |
27 |
Correct |
21 ms |
344 KB |
Output is correct |
28 |
Correct |
33 ms |
344 KB |
Output is correct |
29 |
Correct |
22 ms |
344 KB |
Output is correct |
30 |
Correct |
210 ms |
608 KB |
Output is correct |
31 |
Correct |
194 ms |
344 KB |
Output is correct |
32 |
Correct |
191 ms |
344 KB |
Output is correct |
33 |
Correct |
304 ms |
600 KB |
Output is correct |
34 |
Correct |
306 ms |
344 KB |
Output is correct |
35 |
Correct |
315 ms |
600 KB |
Output is correct |
36 |
Correct |
883 ms |
872 KB |
Output is correct |
37 |
Correct |
870 ms |
1092 KB |
Output is correct |
38 |
Correct |
872 ms |
948 KB |
Output is correct |
39 |
Correct |
818 ms |
972 KB |
Output is correct |
40 |
Correct |
895 ms |
1168 KB |
Output is correct |
41 |
Correct |
885 ms |
1024 KB |
Output is correct |
42 |
Correct |
836 ms |
988 KB |
Output is correct |
43 |
Correct |
857 ms |
1124 KB |
Output is correct |
44 |
Correct |
883 ms |
1256 KB |
Output is correct |
45 |
Correct |
12 ms |
344 KB |
Output is correct |
46 |
Correct |
9 ms |
344 KB |
Output is correct |
47 |
Correct |
20 ms |
344 KB |
Output is correct |
48 |
Correct |
31 ms |
344 KB |
Output is correct |
49 |
Correct |
31 ms |
344 KB |
Output is correct |
50 |
Correct |
197 ms |
460 KB |
Output is correct |
51 |
Correct |
211 ms |
616 KB |
Output is correct |
52 |
Correct |
195 ms |
600 KB |
Output is correct |
53 |
Correct |
326 ms |
600 KB |
Output is correct |
54 |
Correct |
321 ms |
692 KB |
Output is correct |
55 |
Correct |
292 ms |
600 KB |
Output is correct |
56 |
Correct |
864 ms |
1408 KB |
Output is correct |
57 |
Correct |
904 ms |
936 KB |
Output is correct |
58 |
Correct |
887 ms |
1364 KB |
Output is correct |
59 |
Correct |
752 ms |
960 KB |
Output is correct |
60 |
Correct |
788 ms |
932 KB |
Output is correct |
61 |
Correct |
833 ms |
600 KB |
Output is correct |
62 |
Correct |
887 ms |
972 KB |
Output is correct |
63 |
Correct |
829 ms |
1136 KB |
Output is correct |
64 |
Correct |
859 ms |
788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
25 ms |
344 KB |
Output is correct |
3 |
Partially correct |
133 ms |
344 KB |
Output is partially correct |
4 |
Partially correct |
403 ms |
848 KB |
Output is partially correct |
5 |
Partially correct |
865 ms |
1488 KB |
Output is partially correct |
6 |
Correct |
9 ms |
344 KB |
Output is correct |
7 |
Correct |
17 ms |
344 KB |
Output is correct |
8 |
Partially correct |
175 ms |
600 KB |
Output is partially correct |
9 |
Partially correct |
348 ms |
692 KB |
Output is partially correct |
10 |
Partially correct |
870 ms |
892 KB |
Output is partially correct |
11 |
Partially correct |
901 ms |
816 KB |
Output is partially correct |
12 |
Partially correct |
889 ms |
1128 KB |
Output is partially correct |
13 |
Partially correct |
878 ms |
992 KB |
Output is partially correct |
14 |
Correct |
6 ms |
344 KB |
Output is correct |
15 |
Correct |
11 ms |
344 KB |
Output is correct |
16 |
Incorrect |
4 ms |
344 KB |
Incorrect |
17 |
Halted |
0 ms |
0 KB |
- |