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;
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 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... |