This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
#include "fun.h"
const int MAX = 505;
int N;
vi adj[MAX];
int dist[MAX][MAX];
vi createFunTour(int N_g, int Q) {
N = N_g;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
dist[i][j] = hoursRequired(i, j);
if (dist[i][j] == 1)
adj[i].pb(j);
}
}
// start with a diameter point
int start = -1;
int maxd = -1;
for (int i = 0; i < N; i++) {
if (dist[0][i] > maxd) {
start = i;
maxd = dist[0][i];
}
}
vi ans;
vector<bool> vis(N, false);
vis[start] = true;
ans.pb(start);
int curr = start;
for (int i = 0; i < N - 1; i++) {
int nextp = -1;
maxd = -1;
for (int j = 0; j < N; j++) {
if (vis[j])
continue;
if (dist[curr][j] > maxd) {
nextp = j;
maxd = dist[curr][j];
}
}
curr = nextp;
ans.pb(curr);
vis[curr] = true;
}
/* cout<<"ANSWER: ";
for (int x : ans)
cout<<x<<" ";
cout<<endl;*/
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... |