#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
const int nax = 2e5+5;
const int MOD = 1e9+7;
vector<int> adj[256];
bool vis[256];
vector<int> components[256];
void dfs(int x,int p){
components[p].pb(x);
vis[x]=true;
for(auto u:adj[x]){
if(vis[u]) continue;
dfs(u,p);
}return;
}
std::vector<int> longest_trip(int N, int D)
{
for (int i = 0; i < N; ++i)
{
vis[i]=0;
adj[i].clear();
components[i].clear();
}
for (int i = 0; i < N; ++i)
{
for (int j = i+1; j < N; ++j)
{
if(are_connected({i},{j})){
adj[i].pb(j);
adj[j].pb(i);
}
}
}
pair<int,int> big={-1,-1};
for (int i = 0; i < N; ++i)
{
if(vis[i]) continue;
dfs(i,i);
if(big.fi<(int)components[i].size()){
big={(int)components[i].size(),i};
}
}
vector<int> ans;
for(auto u:components[big.se]){
ans.pb(u);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
195 ms |
972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
22 ms |
344 KB |
Output is correct |
3 |
Correct |
154 ms |
344 KB |
Output is correct |
4 |
Correct |
387 ms |
600 KB |
Output is correct |
5 |
Correct |
881 ms |
744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
344 KB |
Output is correct |
2 |
Correct |
21 ms |
344 KB |
Output is correct |
3 |
Correct |
145 ms |
344 KB |
Output is correct |
4 |
Correct |
437 ms |
592 KB |
Output is correct |
5 |
Correct |
869 ms |
1236 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 |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
28 ms |
344 KB |
Output is correct |
3 |
Correct |
148 ms |
344 KB |
Output is correct |
4 |
Correct |
434 ms |
724 KB |
Output is correct |
5 |
Correct |
844 ms |
872 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 |
9 ms |
344 KB |
Output is correct |
2 |
Correct |
26 ms |
344 KB |
Output is correct |
3 |
Partially correct |
163 ms |
344 KB |
Output is partially correct |
4 |
Partially correct |
387 ms |
480 KB |
Output is partially correct |
5 |
Partially correct |
793 ms |
1040 KB |
Output is partially correct |
6 |
Incorrect |
1 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |