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 <vector>
using namespace std;
typedef pair<int, int> pii;
const int maxn = 510;
int dist[maxn][maxn];
vector<int> G[maxn];
int hight[maxn];
bool vis[maxn];
vector<int> createFunTour(int N, int Q)
{
vector<int> ans;
int mx = -1;
int f = -1;
for(int i = 0; i < N; i++)
{
for(int j = i+1; j < N; j++)
{
dist[i][j] = dist[j][i] = hoursRequired(i, j);
if(mx < dist[i][j])
{
mx = dist[i][j];
f = i;
}
if(dist[i][j] == 1)
{
//G[i].push_back(j);
//G[j].push_back(i);
}
}
}
ans.push_back(f);
vis[f] = true;
for(int i = 1; i < N; i++)
{
pii mxdf = pii(-1, f);
for(int j = 0; j < N; j++)
{
if(!vis[j])
mxdf = max(mxdf, pii(dist[f][j], j));
}
f = mxdf.second;
ans.push_back(f);
vis[f] = true;
}
return ans;
}
# | 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... |