#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
const int MAXN = 260;
const int inf=1000000500ll;
const long long oo =1000000000000000500ll;
const int MOD = (int)1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> pi;
vector<int>out;
int n,d;
bool mat[MAXN][MAXN];
bool vis[MAXN];
void dfs(int x){
vis[x]=1;
out.push_back(x);
for(int i=1;i<=n;i++){
if(mat[x][i] && !vis[i]){
dfs(i);
return;
}
}
}
vector<int>solve(int st){
memset(vis,0,sizeof vis);
out.clear();
dfs(st);
return out;
}
std::vector<int> longest_trip(int N, int D)
{
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
mat[i][j]=0;
}
}
n=N;
d=D;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
vector<int>A;A.push_back(i);
vector<int>B;B.push_back(j);
mat[i][j]=mat[j][i]=are_connected(A,B);
}
}
vector<int> ans;
for(int i=0;i<n;i++){//starting point
vector<int>res=solve(i);
if(res.size()>ans.size())ans=res;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
194 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
344 KB |
Output is correct |
2 |
Correct |
25 ms |
344 KB |
Output is correct |
3 |
Correct |
113 ms |
344 KB |
Output is correct |
4 |
Correct |
352 ms |
456 KB |
Output is correct |
5 |
Correct |
769 ms |
484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
344 KB |
Output is correct |
2 |
Correct |
24 ms |
344 KB |
Output is correct |
3 |
Correct |
122 ms |
344 KB |
Output is correct |
4 |
Correct |
328 ms |
456 KB |
Output is correct |
5 |
Correct |
788 ms |
484 KB |
Output is correct |
6 |
Incorrect |
0 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
20 ms |
344 KB |
Output is correct |
3 |
Correct |
139 ms |
344 KB |
Output is correct |
4 |
Correct |
362 ms |
460 KB |
Output is correct |
5 |
Correct |
684 ms |
484 KB |
Output is correct |
6 |
Correct |
8 ms |
596 KB |
Output is correct |
7 |
Correct |
26 ms |
344 KB |
Output is correct |
8 |
Correct |
120 ms |
444 KB |
Output is correct |
9 |
Correct |
258 ms |
504 KB |
Output is correct |
10 |
Correct |
763 ms |
484 KB |
Output is correct |
11 |
Correct |
754 ms |
484 KB |
Output is correct |
12 |
Correct |
761 ms |
484 KB |
Output is correct |
13 |
Correct |
733 ms |
484 KB |
Output is correct |
14 |
Correct |
6 ms |
344 KB |
Output is correct |
15 |
Correct |
10 ms |
344 KB |
Output is correct |
16 |
Correct |
40 ms |
344 KB |
Output is correct |
17 |
Correct |
73 ms |
344 KB |
Output is correct |
18 |
Correct |
115 ms |
600 KB |
Output is correct |
19 |
Correct |
259 ms |
592 KB |
Output is correct |
20 |
Correct |
236 ms |
344 KB |
Output is correct |
21 |
Correct |
765 ms |
1112 KB |
Output is correct |
22 |
Correct |
785 ms |
488 KB |
Output is correct |
23 |
Correct |
756 ms |
600 KB |
Output is correct |
24 |
Correct |
740 ms |
480 KB |
Output is correct |
25 |
Correct |
8 ms |
344 KB |
Output is correct |
26 |
Correct |
9 ms |
344 KB |
Output is correct |
27 |
Correct |
24 ms |
344 KB |
Output is correct |
28 |
Correct |
25 ms |
344 KB |
Output is correct |
29 |
Correct |
22 ms |
344 KB |
Output is correct |
30 |
Correct |
146 ms |
344 KB |
Output is correct |
31 |
Correct |
172 ms |
344 KB |
Output is correct |
32 |
Correct |
173 ms |
344 KB |
Output is correct |
33 |
Correct |
240 ms |
464 KB |
Output is correct |
34 |
Correct |
232 ms |
344 KB |
Output is correct |
35 |
Correct |
252 ms |
344 KB |
Output is correct |
36 |
Correct |
742 ms |
596 KB |
Output is correct |
37 |
Correct |
776 ms |
596 KB |
Output is correct |
38 |
Correct |
691 ms |
480 KB |
Output is correct |
39 |
Correct |
743 ms |
480 KB |
Output is correct |
40 |
Correct |
722 ms |
480 KB |
Output is correct |
41 |
Correct |
702 ms |
484 KB |
Output is correct |
42 |
Correct |
707 ms |
1008 KB |
Output is correct |
43 |
Correct |
753 ms |
856 KB |
Output is correct |
44 |
Correct |
768 ms |
480 KB |
Output is correct |
45 |
Correct |
8 ms |
344 KB |
Output is correct |
46 |
Correct |
10 ms |
344 KB |
Output is correct |
47 |
Correct |
25 ms |
344 KB |
Output is correct |
48 |
Correct |
21 ms |
344 KB |
Output is correct |
49 |
Correct |
20 ms |
344 KB |
Output is correct |
50 |
Correct |
154 ms |
344 KB |
Output is correct |
51 |
Correct |
171 ms |
344 KB |
Output is correct |
52 |
Correct |
150 ms |
440 KB |
Output is correct |
53 |
Correct |
275 ms |
460 KB |
Output is correct |
54 |
Correct |
292 ms |
452 KB |
Output is correct |
55 |
Correct |
238 ms |
592 KB |
Output is correct |
56 |
Correct |
738 ms |
492 KB |
Output is correct |
57 |
Correct |
755 ms |
496 KB |
Output is correct |
58 |
Correct |
724 ms |
496 KB |
Output is correct |
59 |
Correct |
704 ms |
496 KB |
Output is correct |
60 |
Correct |
761 ms |
596 KB |
Output is correct |
61 |
Correct |
727 ms |
748 KB |
Output is correct |
62 |
Correct |
726 ms |
500 KB |
Output is correct |
63 |
Correct |
707 ms |
492 KB |
Output is correct |
64 |
Correct |
694 ms |
496 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 |
Partially correct |
109 ms |
344 KB |
Output is partially correct |
4 |
Partially correct |
335 ms |
460 KB |
Output is partially correct |
5 |
Partially correct |
713 ms |
484 KB |
Output is partially correct |
6 |
Incorrect |
0 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |