#include "longesttrip.h"
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(ll i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define imp(v) for(auto messi:v)cout<<messi<<" "; cout<<"\n"
using namespace std;
typedef int ll;
typedef pair<ll,ll> ii;
#define ask are_connected
const ll MAXN=300;
vector<ll>g[MAXN];
ll n,d;
vector<ll>res;
vector<ll>p;
ll vis[MAXN];
void dfs(ll x){
vis[x]=1;
p.pb(x);
if(SZ(p)>SZ(res))res=p;
for(auto y:g[x])if(!vis[y])dfs(y);
p.pop_back();
}
vector<int> longest_trip(int N, int D){
n=N,d=D;
fore(i,0,n){
g[i].clear();
}
res.clear();
fore(i,0,n)fore(j,i+1,n){
if(ask({i},{j}))g[i].pb(j),g[j].pb(i);
}
fore(x,0,n){
fore(i,0,n)vis[i]=0;
p.clear();
dfs(x);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
352 KB |
Output is correct |
2 |
Correct |
193 ms |
2160 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 |
Correct |
128 ms |
612 KB |
Output is correct |
4 |
Correct |
342 ms |
1228 KB |
Output is correct |
5 |
Correct |
763 ms |
1380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
32 ms |
344 KB |
Output is correct |
3 |
Correct |
126 ms |
704 KB |
Output is correct |
4 |
Correct |
352 ms |
1236 KB |
Output is correct |
5 |
Correct |
836 ms |
1212 KB |
Output is correct |
6 |
Correct |
6 ms |
344 KB |
Output is correct |
7 |
Correct |
21 ms |
344 KB |
Output is correct |
8 |
Correct |
122 ms |
856 KB |
Output is correct |
9 |
Correct |
273 ms |
704 KB |
Output is correct |
10 |
Correct |
809 ms |
1868 KB |
Output is correct |
11 |
Correct |
858 ms |
1376 KB |
Output is correct |
12 |
Correct |
802 ms |
1836 KB |
Output is correct |
13 |
Correct |
812 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
26 ms |
344 KB |
Output is correct |
3 |
Correct |
123 ms |
1112 KB |
Output is correct |
4 |
Correct |
369 ms |
1228 KB |
Output is correct |
5 |
Correct |
819 ms |
1564 KB |
Output is correct |
6 |
Correct |
6 ms |
344 KB |
Output is correct |
7 |
Correct |
22 ms |
344 KB |
Output is correct |
8 |
Correct |
120 ms |
856 KB |
Output is correct |
9 |
Correct |
288 ms |
724 KB |
Output is correct |
10 |
Correct |
794 ms |
1560 KB |
Output is correct |
11 |
Correct |
816 ms |
1380 KB |
Output is correct |
12 |
Correct |
817 ms |
1820 KB |
Output is correct |
13 |
Correct |
808 ms |
1560 KB |
Output is correct |
14 |
Correct |
7 ms |
344 KB |
Output is correct |
15 |
Correct |
10 ms |
344 KB |
Output is correct |
16 |
Correct |
44 ms |
344 KB |
Output is correct |
17 |
Correct |
90 ms |
856 KB |
Output is correct |
18 |
Correct |
136 ms |
1368 KB |
Output is correct |
19 |
Correct |
282 ms |
872 KB |
Output is correct |
20 |
Correct |
290 ms |
952 KB |
Output is correct |
21 |
Correct |
808 ms |
1592 KB |
Output is correct |
22 |
Correct |
839 ms |
1872 KB |
Output is correct |
23 |
Correct |
844 ms |
1664 KB |
Output is correct |
24 |
Correct |
806 ms |
1900 KB |
Output is correct |
25 |
Correct |
9 ms |
344 KB |
Output is correct |
26 |
Correct |
9 ms |
344 KB |
Output is correct |
27 |
Correct |
20 ms |
344 KB |
Output is correct |
28 |
Correct |
21 ms |
344 KB |
Output is correct |
29 |
Correct |
18 ms |
344 KB |
Output is correct |
30 |
Correct |
171 ms |
700 KB |
Output is correct |
31 |
Correct |
196 ms |
972 KB |
Output is correct |
32 |
Correct |
154 ms |
1208 KB |
Output is correct |
33 |
Correct |
276 ms |
1116 KB |
Output is correct |
34 |
Correct |
294 ms |
632 KB |
Output is correct |
35 |
Correct |
278 ms |
1112 KB |
Output is correct |
36 |
Correct |
763 ms |
1384 KB |
Output is correct |
37 |
Correct |
823 ms |
1100 KB |
Output is correct |
38 |
Correct |
807 ms |
1364 KB |
Output is correct |
39 |
Correct |
743 ms |
1832 KB |
Output is correct |
40 |
Correct |
756 ms |
1288 KB |
Output is correct |
41 |
Correct |
756 ms |
1036 KB |
Output is correct |
42 |
Correct |
802 ms |
1212 KB |
Output is correct |
43 |
Correct |
795 ms |
1452 KB |
Output is correct |
44 |
Correct |
773 ms |
1348 KB |
Output is correct |
45 |
Correct |
10 ms |
344 KB |
Output is correct |
46 |
Correct |
8 ms |
344 KB |
Output is correct |
47 |
Correct |
21 ms |
344 KB |
Output is correct |
48 |
Correct |
23 ms |
340 KB |
Output is correct |
49 |
Correct |
22 ms |
344 KB |
Output is correct |
50 |
Correct |
179 ms |
716 KB |
Output is correct |
51 |
Correct |
165 ms |
704 KB |
Output is correct |
52 |
Correct |
165 ms |
960 KB |
Output is correct |
53 |
Correct |
255 ms |
1216 KB |
Output is correct |
54 |
Correct |
274 ms |
1132 KB |
Output is correct |
55 |
Correct |
274 ms |
988 KB |
Output is correct |
56 |
Correct |
882 ms |
1516 KB |
Output is correct |
57 |
Correct |
800 ms |
1316 KB |
Output is correct |
58 |
Correct |
832 ms |
1368 KB |
Output is correct |
59 |
Correct |
770 ms |
1652 KB |
Output is correct |
60 |
Correct |
754 ms |
1780 KB |
Output is correct |
61 |
Correct |
768 ms |
2028 KB |
Output is correct |
62 |
Correct |
718 ms |
1032 KB |
Output is correct |
63 |
Correct |
808 ms |
1496 KB |
Output is correct |
64 |
Correct |
818 ms |
1220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
352 KB |
Output is correct |
2 |
Correct |
26 ms |
596 KB |
Output is correct |
3 |
Partially correct |
124 ms |
864 KB |
Output is partially correct |
4 |
Partially correct |
376 ms |
1232 KB |
Output is partially correct |
5 |
Partially correct |
824 ms |
1248 KB |
Output is partially correct |
6 |
Correct |
7 ms |
344 KB |
Output is correct |
7 |
Correct |
21 ms |
344 KB |
Output is correct |
8 |
Partially correct |
136 ms |
856 KB |
Output is partially correct |
9 |
Partially correct |
260 ms |
864 KB |
Output is partially correct |
10 |
Partially correct |
866 ms |
1304 KB |
Output is partially correct |
11 |
Partially correct |
856 ms |
1384 KB |
Output is partially correct |
12 |
Partially correct |
822 ms |
1352 KB |
Output is partially correct |
13 |
Partially correct |
786 ms |
1488 KB |
Output is partially correct |
14 |
Correct |
7 ms |
344 KB |
Output is correct |
15 |
Correct |
11 ms |
344 KB |
Output is correct |
16 |
Incorrect |
5 ms |
340 KB |
Incorrect |
17 |
Halted |
0 ms |
0 KB |
- |