Submission #840600

# Submission time Handle Problem Language Result Execution time Memory
840600 2023-08-31T14:19:46 Z Minindu206 Longest Trip (IOI23_longesttrip) C++17
0 / 100
1 ms 208 KB
#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
int mxlen = INT_MIN;
vector<int> ans;
void dfs(vector<int> adj[], int node, int cnt, vector<int> &vis, vector<int> temp)
{
    vis[node] = 1;
    int cur = 0;
    for (int a : adj[node])
    {
        if (!vis[a])
        {
            cur = cnt + 1;
            temp.push_back(a);
            dfs(adj, a, cur, vis, temp);
        }

        if (mxlen < cur)
            mxlen = cur;
        ans.clear();
        ans = temp;
        temp.pop_back();
        cur = 0;
    }
}

vector<int> longest_trip(int n, int d)
{
    vector<int> adj[n];
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (are_connected({i}, {j}))
            {
                adj[i].push_back(j);
                adj[j].push_back(i);
            }
        }
    }
    vector<int> vis, temp;
    for(int i=0;i<n;i++)
    {
        vis.clear();
        temp.clear();
        vis.resize(n, 0);
        temp.push_back(i);
        dfs(adj, i, 0, vis, temp);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB non-disjoint arrays
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB non-disjoint arrays
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB non-disjoint arrays
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB non-disjoint arrays
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB non-disjoint arrays
2 Halted 0 ms 0 KB -