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;
vector<int> createFunTour(int N, int Q) {
vector<vector<int>> dist(N,vector<int>(N));
for(int i = 0; i < N;i++)
for(int j = i+1;j < N;j++) {
dist[i][j] = hoursRequired(i,j);
dist[j][i] = dist[i][j];
}
// for(auto a:dist)
// {
// for(auto b:a)
// cout<<b<<' ';
// cout<<'\n';
// }
vector<int> vi(N);
iota(vi.begin(),vi.end(),0);
int helper = 0;
auto cmp = [&](int a, int b){
// cout<<helper<<' '<<a<<' '<<b<<"\n";
return dist[helper][a] < dist[helper][b];
};
int end1 = *max_element(vi.begin(),vi.end(),cmp);
vector<int> ans(1,end1);
vi.erase(find(vi.begin(),vi.end(),end1));
while(!vi.empty()) {
helper = ans.back();
end1 = *max_element(vi.begin(), vi.end(), cmp);
vi.erase(find(vi.begin(),vi.end(),end1));
ans.push_back(end1);
}
// for(auto a:ans)
// cout<<a<<' ';
// cout<<'\n';
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... |