제출 #977957

#제출 시각아이디문제언어결과실행 시간메모리
977957Tuanlinh123즐거운 행로 (APIO20_fun)C++17
26 / 100
78 ms17088 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...