Submission #413286

#TimeUsernameProblemLanguageResultExecution timeMemory
413286ak2006Fun Tour (APIO20_fun)C++14
26 / 100
267 ms524292 KiB
#include <bits/stdc++.h> #include "fun.h"; using namespace std; using vi = vector<int>; using vvi = vector<vi>; using vb = vector<bool>; vi createFunTour(int n, int q) { vi ret(n); vb vis(n); vvi dist(n,vi(n)); int cnt = 1; int mx = 0; int si = -1,sj = -1; 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]; if (dist[i][j] > mx){ mx = dist[i][j]; si = i; sj = j; } } ret[0] = si; vis[si] = 1; while (cnt < n){ mx = 0; int nsi = -1; for (int j = 0;j<n;j++){ if (dist[si][j] > mx && !vis[j]){ mx = dist[si][j]; nsi = j; } } ret[cnt++] = nsi; si = nsi; vis[si] = 1; } return ret; }

Compilation message (stderr)

fun.cpp:2:17: warning: extra tokens at end of #include directive
    2 | #include "fun.h";
      |                 ^
fun.cpp: In function 'vi createFunTour(int, int)':
fun.cpp:14:15: warning: variable 'sj' set but not used [-Wunused-but-set-variable]
   14 |   int si = -1,sj = -1;
      |               ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...