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 "fun.h"
#include<bits/stdc++.h>
#define ll int
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
#define sz(a) ((ll)(a).size())
using namespace std;
const ll maxn=100005;
ll check[maxn];
vector <ll> A[maxn];
vector<int> createFunTour(int n, int Q)
{
for (ll i=0; i<n; i++)
for (ll j=i+1; j<n; j++)
if (hoursRequired(i, j)==1)
A[i].pb(j), A[j].pb(i);
auto furthest=[&](ll r)
{
vector <ll> dis(n, -1);
queue <ll> q; q.push(r), dis[r]=0;
pll Max={0, 0};
while (sz(q))
{
ll u=q.front(); q.pop();
Max=max(Max, {dis[u], u});
for (ll v:A[u])
if (!check[v] && dis[v]==-1)
dis[v]=dis[u]+1, q.push(v);
}
return Max.se;
};
vector <ll> tour;
ll cr=furthest(0); tour.pb(cr), check[cr]=1;
for (ll i=1; i<n; i++)
cr=furthest(cr), tour.pb(cr), check[cr]=1;
return tour;
}
# | 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... |