Submission #982413

#TimeUsernameProblemLanguageResultExecution timeMemory
982413MarcusFun Tour (APIO20_fun)C++17
26 / 100
257 ms524288 KiB
#include "fun.h" #include <bits/stdc++.h> using namespace std; #include <vector> int n, q; vector<vector<int>> adj(1e5); std::vector<int> createFunTour(int N, int Q) { n=N; q=Q; vector<vector<int>> dist(n, vector<int>(n, -1)); for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { dist[i][j] = hoursRequired(i, j); } } vector<int> answer; pair<int, int> maxzero = {-1, -1}; for (int i=0; i<n; i++) { if (dist[0][i] > maxzero.first) {maxzero = {dist[0][i], i};} } vector<int> visited(n); answer.push_back(maxzero.second); visited[answer.back()] = true; while ((int)answer.size() < n) { pair<int, int> maximal = {-1, -1}; for (int i=0; i<n; i++) { if (visited[i]) continue; if (dist[answer.back()][i] > maximal.first) {maximal = {dist[answer.back()][i], i};} } answer.push_back(maximal.second); visited[answer.back()] = true; } return answer; }
#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...