#pragma GCC optimize("O2")
#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 |
220 ms |
1612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
23 ms |
344 KB |
Output is correct |
3 |
Correct |
163 ms |
344 KB |
Output is correct |
4 |
Correct |
418 ms |
488 KB |
Output is correct |
5 |
Correct |
930 ms |
616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
344 KB |
Output is correct |
2 |
Correct |
22 ms |
344 KB |
Output is correct |
3 |
Correct |
171 ms |
344 KB |
Output is correct |
4 |
Correct |
399 ms |
704 KB |
Output is correct |
5 |
Correct |
910 ms |
856 KB |
Output is correct |
6 |
Correct |
6 ms |
344 KB |
Output is correct |
7 |
Correct |
27 ms |
344 KB |
Output is correct |
8 |
Correct |
148 ms |
344 KB |
Output is correct |
9 |
Correct |
314 ms |
344 KB |
Output is correct |
10 |
Correct |
826 ms |
1108 KB |
Output is correct |
11 |
Correct |
953 ms |
1112 KB |
Output is correct |
12 |
Correct |
770 ms |
728 KB |
Output is correct |
13 |
Correct |
724 ms |
856 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 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 |
391 ms |
488 KB |
Output is correct |
5 |
Correct |
854 ms |
708 KB |
Output is correct |
6 |
Correct |
10 ms |
344 KB |
Output is correct |
7 |
Correct |
19 ms |
344 KB |
Output is correct |
8 |
Correct |
159 ms |
440 KB |
Output is correct |
9 |
Correct |
331 ms |
668 KB |
Output is correct |
10 |
Correct |
887 ms |
724 KB |
Output is correct |
11 |
Correct |
883 ms |
912 KB |
Output is correct |
12 |
Correct |
905 ms |
1104 KB |
Output is correct |
13 |
Correct |
933 ms |
876 KB |
Output is correct |
14 |
Correct |
8 ms |
344 KB |
Output is correct |
15 |
Correct |
13 ms |
344 KB |
Output is correct |
16 |
Correct |
35 ms |
344 KB |
Output is correct |
17 |
Correct |
91 ms |
344 KB |
Output is correct |
18 |
Correct |
117 ms |
344 KB |
Output is correct |
19 |
Correct |
339 ms |
344 KB |
Output is correct |
20 |
Correct |
343 ms |
600 KB |
Output is correct |
21 |
Correct |
921 ms |
1216 KB |
Output is correct |
22 |
Correct |
856 ms |
852 KB |
Output is correct |
23 |
Correct |
922 ms |
948 KB |
Output is correct |
24 |
Correct |
913 ms |
944 KB |
Output is correct |
25 |
Correct |
11 ms |
344 KB |
Output is correct |
26 |
Correct |
6 ms |
344 KB |
Output is correct |
27 |
Correct |
22 ms |
344 KB |
Output is correct |
28 |
Correct |
22 ms |
344 KB |
Output is correct |
29 |
Correct |
30 ms |
344 KB |
Output is correct |
30 |
Correct |
189 ms |
344 KB |
Output is correct |
31 |
Correct |
203 ms |
444 KB |
Output is correct |
32 |
Correct |
202 ms |
344 KB |
Output is correct |
33 |
Correct |
289 ms |
456 KB |
Output is correct |
34 |
Correct |
321 ms |
600 KB |
Output is correct |
35 |
Correct |
346 ms |
968 KB |
Output is correct |
36 |
Correct |
944 ms |
872 KB |
Output is correct |
37 |
Correct |
900 ms |
1244 KB |
Output is correct |
38 |
Correct |
895 ms |
1092 KB |
Output is correct |
39 |
Correct |
906 ms |
1384 KB |
Output is correct |
40 |
Correct |
905 ms |
1000 KB |
Output is correct |
41 |
Correct |
879 ms |
1028 KB |
Output is correct |
42 |
Correct |
878 ms |
768 KB |
Output is correct |
43 |
Correct |
858 ms |
1200 KB |
Output is correct |
44 |
Correct |
794 ms |
1384 KB |
Output is correct |
45 |
Correct |
6 ms |
344 KB |
Output is correct |
46 |
Correct |
6 ms |
344 KB |
Output is correct |
47 |
Correct |
21 ms |
344 KB |
Output is correct |
48 |
Correct |
19 ms |
344 KB |
Output is correct |
49 |
Correct |
26 ms |
344 KB |
Output is correct |
50 |
Correct |
211 ms |
604 KB |
Output is correct |
51 |
Correct |
199 ms |
436 KB |
Output is correct |
52 |
Correct |
205 ms |
428 KB |
Output is correct |
53 |
Correct |
320 ms |
848 KB |
Output is correct |
54 |
Correct |
294 ms |
344 KB |
Output is correct |
55 |
Correct |
282 ms |
460 KB |
Output is correct |
56 |
Correct |
853 ms |
852 KB |
Output is correct |
57 |
Correct |
783 ms |
760 KB |
Output is correct |
58 |
Correct |
802 ms |
1012 KB |
Output is correct |
59 |
Correct |
764 ms |
1232 KB |
Output is correct |
60 |
Correct |
852 ms |
1228 KB |
Output is correct |
61 |
Correct |
824 ms |
760 KB |
Output is correct |
62 |
Correct |
830 ms |
608 KB |
Output is correct |
63 |
Correct |
823 ms |
1008 KB |
Output is correct |
64 |
Correct |
796 ms |
956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
22 ms |
344 KB |
Output is correct |
3 |
Partially correct |
149 ms |
456 KB |
Output is partially correct |
4 |
Partially correct |
416 ms |
712 KB |
Output is partially correct |
5 |
Partially correct |
898 ms |
788 KB |
Output is partially correct |
6 |
Correct |
7 ms |
344 KB |
Output is correct |
7 |
Correct |
25 ms |
344 KB |
Output is correct |
8 |
Partially correct |
154 ms |
448 KB |
Output is partially correct |
9 |
Partially correct |
299 ms |
592 KB |
Output is partially correct |
10 |
Partially correct |
811 ms |
1004 KB |
Output is partially correct |
11 |
Partially correct |
923 ms |
856 KB |
Output is partially correct |
12 |
Partially correct |
896 ms |
884 KB |
Output is partially correct |
13 |
Partially correct |
864 ms |
1008 KB |
Output is partially correct |
14 |
Correct |
7 ms |
344 KB |
Output is correct |
15 |
Correct |
17 ms |
344 KB |
Output is correct |
16 |
Incorrect |
9 ms |
344 KB |
Incorrect |
17 |
Halted |
0 ms |
0 KB |
- |