이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |