Submission #1032272

#TimeUsernameProblemLanguageResultExecution timeMemory
1032272TonylFun Tour (APIO20_fun)C++17
26 / 100
233 ms524288 KiB
#include "fun.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; using pi = pair<int,int>; using ll = long long; #define REP(i,n) for (int i = 0; i < n; i++) #define trav(a,x) for (auto &a : x) #define all(x) (x).begin(), (x).end() #define D(x) cerr << #x << ": " << x << endl; map<pi, int> dists; int ask_dist(int a, int b) { if (a > b) swap(a,b); if (!dists.count({a,b})) dists[{a,b}] = hoursRequired(a,b); return dists[{a,b}]; } //attractionsBehind int n, q; std::vector<int> createFunTour(int N, int Q) { n = N; q = Q; vector<pair<int,pi>> alld(n*n); REP(i,n) { REP(j,n) alld[i*n+j] = {ask_dist(i,j), {i,j}}; } sort(all(alld)); vector<bool> done(n, 0); int s = alld.back().second.first; vi ans = {s}; done[s] = 1; D(s); while (--n) { int best = s; REP(i,N) { if (done[i]) continue; if (ask_dist(s, best) < ask_dist(s, i)) best = i; } assert(s != best); s = best; //D(s); done[s] = 1; ans.push_back(s); } 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...