#include <bits/stdc++.h>
using namespace std;
bool are_connected(vector<int>A,vector<int>B);
vector<vector<int>>graph;
vector<bool>v;
vector<int>path;
void dfs(int vecino){
v[vecino]=true;
path.push_back(vecino);
for(int padre:graph[vecino]){
if(!v[padre]){
dfs(padre);
}
}
}
vector<int> longest_trip(int N, int D){
graph.clear();
v.clear();
graph.resize(N,vector<int>());
v.resize(N,false);
for(int i=0; i<N; i++){
for(int j=i+1; j<N; j++){
if(are_connected({i}, {j})){
graph[i].push_back(j);
graph[j].push_back(i);
}
}
}
vector<int>ans;
for(int i=0;i<N;i++){
path.clear();
for(int j=0;j<N;j++){
v[j]=false;
}
dfs(i);
if(path.size()>ans.size()){
ans=path;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
231 ms |
692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
22 ms |
344 KB |
Output is correct |
3 |
Correct |
144 ms |
444 KB |
Output is correct |
4 |
Correct |
464 ms |
948 KB |
Output is correct |
5 |
Correct |
943 ms |
1048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
344 KB |
Output is correct |
2 |
Correct |
31 ms |
344 KB |
Output is correct |
3 |
Correct |
174 ms |
344 KB |
Output is correct |
4 |
Correct |
458 ms |
724 KB |
Output is correct |
5 |
Correct |
946 ms |
840 KB |
Output is correct |
6 |
Incorrect |
1 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
15 ms |
344 KB |
Output is correct |
3 |
Correct |
154 ms |
416 KB |
Output is correct |
4 |
Correct |
433 ms |
464 KB |
Output is correct |
5 |
Correct |
862 ms |
1008 KB |
Output is correct |
6 |
Incorrect |
0 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
20 ms |
344 KB |
Output is correct |
3 |
Partially correct |
140 ms |
344 KB |
Output is partially correct |
4 |
Partially correct |
421 ms |
344 KB |
Output is partially correct |
5 |
Partially correct |
911 ms |
848 KB |
Output is partially correct |
6 |
Incorrect |
0 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |