#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);
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].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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
209 ms |
712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
26 ms |
344 KB |
Output is correct |
3 |
Correct |
136 ms |
344 KB |
Output is correct |
4 |
Correct |
429 ms |
344 KB |
Output is correct |
5 |
Correct |
987 ms |
664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
31 ms |
344 KB |
Output is correct |
3 |
Correct |
160 ms |
344 KB |
Output is correct |
4 |
Correct |
398 ms |
668 KB |
Output is correct |
5 |
Correct |
963 ms |
680 KB |
Output is correct |
6 |
Correct |
8 ms |
344 KB |
Output is correct |
7 |
Correct |
28 ms |
344 KB |
Output is correct |
8 |
Correct |
145 ms |
344 KB |
Output is correct |
9 |
Correct |
348 ms |
712 KB |
Output is correct |
10 |
Correct |
916 ms |
1208 KB |
Output is correct |
11 |
Correct |
894 ms |
916 KB |
Output is correct |
12 |
Correct |
897 ms |
864 KB |
Output is correct |
13 |
Correct |
889 ms |
792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
24 ms |
344 KB |
Output is correct |
3 |
Correct |
129 ms |
344 KB |
Output is correct |
4 |
Correct |
468 ms |
620 KB |
Output is correct |
5 |
Correct |
886 ms |
844 KB |
Output is correct |
6 |
Correct |
5 ms |
344 KB |
Output is correct |
7 |
Correct |
27 ms |
344 KB |
Output is correct |
8 |
Correct |
151 ms |
344 KB |
Output is correct |
9 |
Correct |
356 ms |
592 KB |
Output is correct |
10 |
Correct |
873 ms |
1364 KB |
Output is correct |
11 |
Correct |
923 ms |
784 KB |
Output is correct |
12 |
Correct |
911 ms |
976 KB |
Output is correct |
13 |
Correct |
935 ms |
976 KB |
Output is correct |
14 |
Correct |
5 ms |
340 KB |
Output is correct |
15 |
Correct |
11 ms |
344 KB |
Output is correct |
16 |
Correct |
54 ms |
344 KB |
Output is correct |
17 |
Correct |
87 ms |
344 KB |
Output is correct |
18 |
Correct |
137 ms |
440 KB |
Output is correct |
19 |
Correct |
332 ms |
600 KB |
Output is correct |
20 |
Correct |
344 ms |
344 KB |
Output is correct |
21 |
Correct |
953 ms |
976 KB |
Output is correct |
22 |
Correct |
899 ms |
1008 KB |
Output is correct |
23 |
Correct |
874 ms |
784 KB |
Output is correct |
24 |
Correct |
884 ms |
844 KB |
Output is correct |
25 |
Correct |
7 ms |
344 KB |
Output is correct |
26 |
Correct |
7 ms |
344 KB |
Output is correct |
27 |
Correct |
22 ms |
344 KB |
Output is correct |
28 |
Correct |
20 ms |
344 KB |
Output is correct |
29 |
Correct |
19 ms |
344 KB |
Output is correct |
30 |
Correct |
204 ms |
344 KB |
Output is correct |
31 |
Correct |
200 ms |
592 KB |
Output is correct |
32 |
Correct |
189 ms |
344 KB |
Output is correct |
33 |
Correct |
310 ms |
600 KB |
Output is correct |
34 |
Correct |
315 ms |
344 KB |
Output is correct |
35 |
Correct |
337 ms |
960 KB |
Output is correct |
36 |
Correct |
894 ms |
852 KB |
Output is correct |
37 |
Correct |
947 ms |
1184 KB |
Output is correct |
38 |
Correct |
870 ms |
1240 KB |
Output is correct |
39 |
Correct |
913 ms |
1220 KB |
Output is correct |
40 |
Correct |
876 ms |
1472 KB |
Output is correct |
41 |
Correct |
858 ms |
864 KB |
Output is correct |
42 |
Correct |
869 ms |
848 KB |
Output is correct |
43 |
Correct |
843 ms |
1180 KB |
Output is correct |
44 |
Correct |
883 ms |
1460 KB |
Output is correct |
45 |
Correct |
8 ms |
344 KB |
Output is correct |
46 |
Correct |
8 ms |
344 KB |
Output is correct |
47 |
Correct |
23 ms |
344 KB |
Output is correct |
48 |
Correct |
26 ms |
344 KB |
Output is correct |
49 |
Correct |
22 ms |
344 KB |
Output is correct |
50 |
Correct |
204 ms |
344 KB |
Output is correct |
51 |
Correct |
243 ms |
436 KB |
Output is correct |
52 |
Correct |
226 ms |
344 KB |
Output is correct |
53 |
Correct |
318 ms |
344 KB |
Output is correct |
54 |
Correct |
370 ms |
592 KB |
Output is correct |
55 |
Correct |
338 ms |
472 KB |
Output is correct |
56 |
Correct |
965 ms |
616 KB |
Output is correct |
57 |
Correct |
934 ms |
984 KB |
Output is correct |
58 |
Correct |
898 ms |
1248 KB |
Output is correct |
59 |
Correct |
909 ms |
1420 KB |
Output is correct |
60 |
Correct |
847 ms |
1036 KB |
Output is correct |
61 |
Correct |
913 ms |
764 KB |
Output is correct |
62 |
Correct |
908 ms |
884 KB |
Output is correct |
63 |
Correct |
877 ms |
1296 KB |
Output is correct |
64 |
Correct |
862 ms |
1264 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
344 KB |
Output is correct |
2 |
Correct |
16 ms |
344 KB |
Output is correct |
3 |
Partially correct |
156 ms |
344 KB |
Output is partially correct |
4 |
Partially correct |
453 ms |
340 KB |
Output is partially correct |
5 |
Partially correct |
905 ms |
948 KB |
Output is partially correct |
6 |
Correct |
5 ms |
344 KB |
Output is correct |
7 |
Correct |
22 ms |
344 KB |
Output is correct |
8 |
Partially correct |
157 ms |
436 KB |
Output is partially correct |
9 |
Partially correct |
314 ms |
600 KB |
Output is partially correct |
10 |
Partially correct |
848 ms |
864 KB |
Output is partially correct |
11 |
Partially correct |
936 ms |
856 KB |
Output is partially correct |
12 |
Partially correct |
722 ms |
884 KB |
Output is partially correct |
13 |
Partially correct |
800 ms |
700 KB |
Output is partially correct |
14 |
Correct |
9 ms |
344 KB |
Output is correct |
15 |
Correct |
13 ms |
344 KB |
Output is correct |
16 |
Incorrect |
6 ms |
344 KB |
Incorrect |
17 |
Halted |
0 ms |
0 KB |
- |