Submission #319473

#TimeUsernameProblemLanguageResultExecution timeMemory
319473VEGAnnFun Tour (APIO20_fun)C++14
26 / 100
15 ms2924 KiB
#include "fun.h" #include <bits/stdc++.h> #define PB push_back #define sz(x) ((int)x.size()) #define i2 array<int,2> #define all(x) x.begin(),x.end() using namespace std; const int N = 100100; vector<int> g[N], ans; int siz[N], glob, mx; bool mrk[N]; void dfs(int v, int p, int len){ if (mx < len){ mx = len; glob = v; } for (int u : g[v]){ if (u == p || mrk[u]) continue; dfs(u, v, len + 1); } } vector<int> createFunTour(int n, int Q) { if (n <= 500){ for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++){ int now = hoursRequired(i, j); if (now == 1){ g[i].PB(j); g[j].PB(i); } } } else { // for (int i = 1; i < n; i++){ // int j = (i - 1) / 2; // // g[i].PB(j); // g[j].PB(i); // } exit(-1); } ans.clear(); mx = -1; dfs(0, -1, 0); for (int it = 0; it < n; it++){ ans.PB(glob); mrk[glob] = 1; mx = -1; dfs(glob, -1, 0); } return ans; }
#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...