This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |