# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1069759 | UmairAhmadMirza | Longest Trip (IOI23_longesttrip) | C++17 | 382 ms | 700 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
bool are_connected(vector<int> A, vector<int> B);
int const MAXN=260;
bool con[MAXN][MAXN];
vector<int> path,longest;
bool vis[MAXN];
int nn;
void dfs(int node){
path.push_back(node);
if(path.size()>longest.size())
longest=path;
vis[node]=1;
for(int i=0;i<nn;i++)
if(vis[i]==0 && are_connected({node},{i}))
dfs(i);
path.pop_back();
}
vector<int> longest_trip(int n, int D){
longest.clear();
nn=n;
for (int i = 0; i < n; ++i)
{
path.clear();
for(int j=0;j<n;j++)
vis[j]=0;
dfs(i);
if(longest.size()*2>=n)
break;
}
return longest;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |