제출 #762662

#제출 시각아이디문제언어결과실행 시간메모리
762662AmirElarbi즐거운 행로 (APIO20_fun)C++14
0 / 100
78 ms15896 KiB
#include <bits/stdc++.h> #define ve vector #define vi vector<int> #define vii vector<ii> #define ii pair<int,int> #define fi first #define se second #define ll long long #define INF 1e9+7 #define pb push_back #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int MOD = 1e9+7; const int nax = 1e5+5; #include "fun.h" int mx = 0, node = 0; vi adj[nax]; bool vis[nax]; void farthest(int u, int p, int dep){ if(mx < dep) node = u, mx = dep; for(auto x : adj[u]){ if(x == p || vis[x] == 1) continue; farthest(x,u,dep+1); } } std::vector<int> createFunTour(int N, int Q) { vi res; for(int i = 0; i < N; i++){ for(int j = i+1; j < N; j++){ if(hoursRequired(i,j) == 1) { adj[i].pb(j); adj[j].pb(i); } } } int root = 0; for (int i = 0; i < N; ++i) { if(adj[i].size() == 1) root = i; } res.pb(root); vis[root] = 1; for (int i = 0; i < N-1; ++i) { node = 0, mx = 0; farthest(root, root, 0); vis[node] = 1; res.pb(node); root = node; } return res; }
#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...