# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
375323 | astoria | Fun Tour (APIO20_fun) | C++14 | 1 ms | 384 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 "bits/stdc++.h"
#include "fun.h"
using namespace std;
std::vector<int> createFunTour(int N, int Q) {
pair<int,int> dist[N][N];
for(int i=0; i<N; i++){
for(int j=0; j<N; j++){
dist[i][j] = {hoursRequired(i,j),j};
}
}
for(int i=0; i<N; i++){
sort(dist[i],dist[i]+N);
reverse(dist[i],dist[i]+N);
}
for(int st=0; st<1; st++){
int v=st,cnt=1; vector<int> ans; ans.push_back(v);
int used[N]; memset(used,0,sizeof(used)); used[v]=1;
int mn = 1e9+100;
while(cnt<N){
int nxt=-1;
for(int j=0; j<N; j++){
if(dist[v][j].first <= mn && !used[dist[v][j].second]){
nxt = dist[v][j].second; mn=min(mn,dist[v][j].first); break;
}
}
if(nxt==-1) break;
used[nxt]=1; cnt++; v=nxt; ans.push_back(v);
}
if(ans.size()==N){
return ans;
}
}
exit(6);
return std::vector<int>(N);
}
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... |