# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
898367 | OAleksa | Fun Tour (APIO20_fun) | C++14 | 312 ms | 524288 KiB |
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>
#define f first
#define s second
using namespace std;
vector<int> createFunTour(int N, int Q) {
int n = N, q = Q;
vector<int> ans(n);
int d[n][n];
for (int i = 0;i < n;i++) {
for (int j = 0;j < n;j++) {
d[i][j] = hoursRequired(i, j);
}
}
int mx = 0;
for (int i = 0;i < n;i++) {
for (int j = 0;j < n;j++)
mx = max(mx, d[i][j]);
}
int p = -1, p1 = -1;
for (int i = 0;i < n;i++) {
int res = 0;
for (int j = 0;j < n;j++)
res = max(res, d[i][j]);
if (res == mx) {
for (int j = 0;j < n;j++) {
if (d[i][j] == mx)
p1 = j;
}
p = i;
break;
}
}
vector<int> vis(n);
assert(p != -1 && p1 != -1);
vis[p] = vis[p1] = 1;
ans[0] = p;
ans[1] = p1;
for (int i = 2;i < n;i++) {
int cur = 0, bst = 0;
for (int j = 0;j < n;j++) {
if (vis[j])
continue;
if (d[p1][j] >= bst) {
bst = d[p1][j];
cur = j;
}
}
vis[cur] = 1;
ans[i] = cur;
p1 = cur;
}
return ans;
}
/*
7 400000
0 1
0 5
0 6
1 2
1 4
2 3
*/
Compilation message (stderr)
# | 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... |