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;
#define all(a) begin(a),end(a)
#define sz(a) (int)a.size()
#define pb push_back
const int mxN = (int)1000;
int dis[mxN][mxN];
bool vis[mxN];
vector<int> createFunTour(int N, int Q) {
vector<int> ans; ans.clear();
int mx = 0;
for(int i = 0; i < N; i++)
for(int j = 0; j < N; j++)
dis[i][j] = hoursRequired(i,j), mx=max(mx,dis[i][j]);
memset(vis,0,sizeof(vis));
for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++){
if(i==j) continue;
if(dis[i][j]!=mx) continue;
int x = i; vis[x] = 1; ans.pb(x);
while(sz(ans)!=N){
int nx = -1, mx_d=0;
for(int k = 0; k < N; k++){
if(vis[k]) continue;
if(mx_d<dis[x][k]) nx=k, mx_d=dis[x][k];
}
x=nx; vis[x] = 1; ans.pb(x);
}
return ans;
}
}
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... |