제출 #414314

#제출 시각아이디문제언어결과실행 시간메모리
414314prvocislo즐거운 행로 (APIO20_fun)C++17
26 / 100
15 ms808 KiB
#include "fun.h" #include <bits/stdc++.h> using namespace std; // int H = hoursRequired(0, N - 1); // int A = attractionsBehind(0, N - 1); const int maxn = 501; int n, q; vector<vector<int> > g(maxn); vector<int> d, vis(maxn, 0); void dfs(int u, int p = -1) { for (int v : g[u]) if (!vis[v] && v != p) d[v] = d[u] + 1, dfs(v, u); } int maxi(int u) { d.assign(n, 0); dfs(u, -1); return max_element(d.begin(), d.end()) - d.begin(); } vector<int> createFunTour(int N, int Q) { n = N, q = Q; for (int i = 0; i < n; i++) for (int j = 0; j < i; j++) { if (hoursRequired(i, j) == 1) g[i].push_back(j), g[j].push_back(i); } vector<int> p; p.push_back(maxi(0)); vis[p.back()] = 1; for (int i = 0; i < n-1; i++) { p.push_back(maxi(p.back())); vis[p.back()] = 1; } return p; }
#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...